I have the following code:
Code:
#include <stdio.h>
#define N 2
int main()
{
int A[N][N];
int i,j;
char text[100];
printf("input\n");
for (i=0;i<N;i++)
for (j=0;j<N;j++)
{
printf("element %d,%d ",i,j);
scanf("%d",&A[i][j]);
}
printf("Input text:\n");
fgets(text,40,stdin);
printf("%s",text);
return 0;
}
The output is:
$./a.out
input
element 0,0 1
element 0,1 2
element 1,0 3
element 1,1 4
Input text:
$
The problem is that it terminates before it reads my string.
What should I change in order to make it work?