0
I want to get a name and put it in my struct element "etudiant.name"
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <Windows.h> typedef struct etud { int age; char name[20]; } etudiant ; int main(void) { int x,i; etudiant tab[100]; i = 0; x = 0; printf("enter la nombres des etud : "); scanf_s("%d",&x); for (i = 0; i < x; i++) { printf("entre l'age = "); scanf_s("%d", &tab[i].age); printf("entre le nom = "); scanf_s("%s", &tab[i].name); } system("PAUSE"); } help me guys it show me error in the line that i want to scan a name and put it in etudiant.name !!
1 Respuesta
0
#include <stdio.h>
#include <conio.h>
typedef struct _etud {
int age;
char name[20];
} etudiant_t;
int main() {
unsigned char x;
etudiant_t tab[100];
printf("enter la nombres des etud : ");
scanf("%i",&x);
for (unsigned char i = 0; i < x; i ++) {
printf("entre l'age = ");
scanf("%i", &tab[i].age);
fflush(stdin);
printf("entre le nom = ");
gets(tab[i].name);
}
_getch();
return 0;
}