pass structure as reference

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • soukat
    New Member
    • Sep 2007
    • 1

    #1

    pass structure as reference

    i have declear one structure typedef struct { char name[20]; int age;} INFO
    another file and create one structure vasrable str1 in main,
    I want to pass the addres for another function linke fun( &str1);
    in this function i am read data from a file like

    void fun ( INFO * str )
    READ (HANDLE, &str,sizeof(str 1));
    that is write or not ?
    i wnat to print info in main
  • hariharanmca
    Top Contributor
    • Dec 2006
    • 1977

    #2
    Originally posted by soukat
    i have declear one structure typedef struct { char name[20]; int age;} INFO
    another file and create one structure vasrable str1 in main,
    I want to pass the addres for another function linke fun( &str1);
    in this function i am read data from a file like

    void fun ( INFO * str )
    READ (HANDLE, &str,sizeof(str 1));
    that is write or not ?
    i wnat to print info in main
    Check where you are declaring to str1?

    I think this thread will help you

    Structure

    Comment

    • Savage
      Recognized Expert Top Contributor
      • Feb 2007
      • 1759

      #3
      Originally posted by soukat
      i have declear one structure typedef struct { char name[20]; int age;} INFO
      another file and create one structure vasrable str1 in main,
      I want to pass the addres for another function linke fun( &str1);
      in this function i am read data from a file like

      void fun ( INFO * str )
      READ (HANDLE, &str,sizeof(str 1));
      that is write or not ?
      i wnat to print info in main
      void fun ( INFO * str ) this is right,but READ (HANDLE, &str,sizeof(str 1)); isn't.

      You will need to read each member of the struct separately.

      Savage

      Comment

      Working...