...

View Full Version : structure



Xiang
12-23-2002, 01:28 PM
Dear sir,

That is occurs error on my C program structure.

#include <stdio.h>
struct student_type
{
char first_name[20];
char family_name[20];
int student_id;
};
main()
{
struct student_type undergraduate;
printf(“Enter first name :”);
gets(undergraduate.first_name);
printf(“Enter family name :”);
gets(undergraduate.family_name);
printf(“Enter student id name :”);
gets(undergraduate.student_id);
printf(“%s %s, id number %d \n”, undergraduate.first_name,
undergraduate.family_name,
undergraduate.student_id,
return 0; }

Josh Campbell
12-23-2002, 04:09 PM
You shouldn't be using gets to get an integer. Use scanf instead.

scanf("%d",&(undergraduate.student_id));

and although I believe that main() works, it is much nicer to say int main(void)

And you forgot to put the ending parenthesis on your last printf. Get rid of that last comma and put );



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum