Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

return pointer to struct in C

typedef struct {
  char name[20];
  int age;
} Info;

Info* GetData() {
  Info *info;

  info = (Info *) malloc( sizeof(Info) );
  scanf("%s", info.name);
  scanf("%d", &info.age);

  return info;
}
Source by cboard.cprogramming.com #
 
PREVIOUS NEXT
Tagged: #return #pointer #struct #C
ADD COMMENT
Topic
Name
5+9 =