I initialized q.size with 7 within main function, Then first it print q.size value as 7, but after the scanf() statement the value of q.size become 0. Why this is happening and how to solve it???
#include <stdio.h>
#include <stdlib.h>
struct sample
{
int size;
int rear;
int front;
};
int main()
{
struct sample q;
q.size=7;
char Ans;
printf("%d\n",q.size);
printf("Enter character : (y/n)");
scanf("%s",&Ans);
printf("%d",q.size);
return 0;
}
Expected result from q.size after scanf() as 7 Actual result is 0