اطلاعیه

Collapse
No announcement yet.

prototype

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    prototype

    منظور از prototype چیه؟

    #2
    پاسخ : prototype

    قطع یقیین با یه گوگل میشد فهمید

    http://en.wikipedia.org/wiki/Function_prototype

    حالا anyway
    داخل برنامه یه فانکشن داری برای اینکه هر جایی از برنامه بتونی این فامکشن رو کال کنی
    نیاز هست که قبلا به کامپایلر بگی که یه همچین فانکشنی داخل کد هست .

    کد:
     #include <stdio.h>
     
     /* 
     * If this prototype is provided, the compiler will catch the error 
     * in main(). If it is omitted, then the error may go unnoticed.
     */
     int fac(int n);       /* Prototype */
     
     int main(void) {       /* Calling function */
       printf("%d\n", fac());  /* Error: forgot argument to fac */
       return 0;
     }
     
     int fac(int n) {       /* Called function Function definition */
     
       if (n == 0) 
         return 1;
       else 
         return n * fac(n - 1);
     }
    از جمله ی رفتگان این راه دراز
    باز آمده ای کو که به ما گوید راز
    هان بر سر این دو راهه از روی نیاز
    چیزی نگذاری که نمی آیی باز

    دیدگاه

    لطفا صبر کنید...
    X