#include<stdio.h>
#include<stdlib.h>
struct student {
char name[30];
};
typedef struct student sv;
int main() {
int i;
sv basedata[50] ;
int totalstudent;
do
{
printf("How many people are there: ");
scanf_s("%i", &totalstudent);
} while (totalstudent<0);
fflush(stdin);
for ( i = 0; i < totalstudent; i++)
{
printf("Person %i name: ", i + 1);
gets(basedata[i].name);
}
}
output:
How many people are there: 1
Person 1 name:
D:\hello\chuong7\x64\Debug\chuong6.exe (process 26572) exited with code 0.
Press any key to close this window . .
Why I can't enter name for Person 1 name when run my program, my program pass to end and I can't gets(basedata[i].name). Sorry I'm just study English picture here