Hello I have a problem with integer. This is my code:
#include <stdio.h>
#include <stdlib.h>
struct data
{
char name[50];
int grade[1];
};
int main()
{
struct data persons[30];
int n = 3;
int i;
for(i=0;i<n;i++)
{
printf("Type person name nr: [%d] ",i+1);
scanf("%s",persons[i].name);
printf("Type grade: (from 1 to 6) ");
scanf("%d",persons[i].grade);
}
for(i=0;i<n;i++)
{
printf("Name [%d]: %s\n",i+1,persons[i].name);
printf("Grade [%d]: %d\n",i+1,persons[i].grade);
}
return 0;
}
And when I type some names and grades the output isn't correct: This is my output