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 !!

31st Mar 2019, 12:28 AM
Omar talbi
Omar talbi - avatar
1 Antwort
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; }
5th Apr 2019, 6:37 AM
Edison
Edison - avatar