extern struct

Discussion in 'C Programming' started by vaibhaw, Apr 16, 2007.

  1. vaibhaw

    vaibhaw

    Joined:
    Apr 16, 2007
    Messages:
    1
    file 1.c
    #include<stdio.h>
    void fun();
    typedef struct
    {
    int aa;
    char* b;
    }a;


    void fun()
    {
    a *a1;
    a1->aa = 12;
    a1->b = (char*)malloc(sizeof(5));
    a1->b = "hello";
    printf("hello====%d\n",a1->b);
    }



    file2.c

    #include<stdio.h>

    extern a1

    int main()
    {


    printf("%d\n",a1->b);

    return 0;
    }


    i am not able to excute file2.c .. how can i use struct member b , without including this file(file1.c) into file2.c ,since both are in the same directory
     
    vaibhaw, Apr 16, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Matthews
    Replies:
    5
    Views:
    2,458
    tom_usenet
    Aug 2, 2004
  2. Chris Fogelklou
    Replies:
    36
    Views:
    1,393
    Chris Fogelklou
    Apr 20, 2004
  3. Rick Anderson

    "extern struct foobar" linux compilation warning

    Rick Anderson, Mar 9, 2005, in forum: C Programming
    Replies:
    10
    Views:
    637
    Chris Torek
    Mar 9, 2005
  4. Steffen Loringer

    Access to extern struct in other header files

    Steffen Loringer, Nov 21, 2005, in forum: C Programming
    Replies:
    13
    Views:
    858
    Zoran Cutura
    Nov 25, 2005
  5. Andre
    Replies:
    5
    Views:
    544
    Keith Thompson
    Jul 17, 2012
Loading...

Share This Page