SORU
18 AĞUSTOS 2011, PERŞEMBE


Kendi başlık oluşturmak C dosyası

Herkes baştan sona basit bir örnekle C üstbilgi dosyası oluşturmak için nasıl açıklayabilir.

CEVAP
18 AĞUSTOS 2011, PERŞEMBE


foo.h

#ifndef FOO_H_   /* Include guard */
#define FOO_H_

int foo(int x);  /* An example function declaration */

#endif // FOO_H_

foo.c

#include "foo.h"  /* Include the header (not strictly necessary here) */

int foo(int x)    /* Function definition */
{
    return x   5;
}

ana.c

#include <stdio.h>
#include "foo.h"  /* Include the header here, to obtain the function declaration */

int main(void)
{
    int y = foo(3);  /* Use the function here */
    printf("%d\n", y);
    return 0;
}

GCC kullanarak derlemek için

gcc -o my_app main.c foo.c

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • AlaskanGrizzly

    AlaskanGrizz

    30 EKİM 2009
  • andyabc45

    andyabc45

    1 Mayıs 2011
  • Jay Will

    Jay Will

    19 NİSAN 2006