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"); }

25th Mar 2020, 1:46 PM
Rawan
Rawan - avatar
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)
25th Mar 2020, 2:26 PM
andriy kan
andriy kan - avatar
+ 1
Try changing %c to %s in the print statement.
25th Mar 2020, 1:48 PM
Avinesh
Avinesh - avatar
0
he print : Segmentation fault ( core dumped )
25th Mar 2020, 1:52 PM
Rawan
Rawan - avatar
0
What does that mean ? :(
25th Mar 2020, 1:57 PM
Rawan
Rawan - avatar
0
It is work ✔️✔️,Thank you so soo sooooooo much for all of you 😩💙💙💙💙💙💙💙💙
25th Mar 2020, 2:49 PM
Rawan
Rawan - avatar