0
Help
This is my program, the problem is my program print only the first Letter of the name ? How can i Fix that #include <stdio.h> int main(int argc, const char * argv []){ // insert code here... char StudentName[10]; int Mark[10]; printf("Enter the name with mark :"); for(int i=0 ; i<10; i++){ scanf("%s",&StudentName[i]); scanf("%d", &Mark[i]); } printf("---------------------------\n"); printf("No.\tName\tMark\n"); printf("---------------------------\n"); for(int i=0; i<10; i++){ printf("%d\t%c\t\t%d\n",i+1,StudentName[i], Mark[i]); printf("-------------------------------\n"); }
5 Réponses
+ 2
1.
StudentName is declared as array of 10 characters.
it should be an array of array of characters, like this:
char StudentName[10][100];
where 100 is max possible length of entered name
2.
printf("%d\t%c\t\t%d\n",i+1,StudentName[i], Mark[i]);
should be
printf("%d\t%s\t\t%d\n",i+1,StudentName[i], Mark[i]);
(replace %c with %s)
+ 1
Try changing %c to %s in the print statement.
0
he print :
Segmentation fault ( core dumped )
0
What does that mean ? :(
0
It is work ✔️✔️,Thank you so soo sooooooo much for all of you 😩💙💙💙💙💙💙💙💙