c - Warning: Format specifies type 'char *' but the argument has type 'char(*)[50]' -
this question has answer here:
i don't know how fix warning, why appears in code. in first phase, code has record names , surname , used structures.
#include <stdio.h> typedef struct student{ char surname[50]; char name[50]; } student; int main() { student a[30]; int aux; int i,j,n; printf("number of students: "); scanf("%d",&n); for(i=0;i<n;i++) { printf("surname:"); scanf("%s",&a[i].surname); printf("name:"); scanf("%s",&a[i].name); } return 0; }
do not use &
in strings surname
in format scanf expecting it.
printf("surname:"); scanf("%s",a[i].surname); printf("name:"); scanf("%s",a[i].name);
also, please read why have set length string in scanf
.
Comments
Post a Comment