c - Warning: Format specifies type 'char *' but the argument has type 'char(*)[50]' -


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.

read string input using scanf


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -