The fragment of code below doesn't work properly.
#include <stdio.h>
#include <string.h>
int main(){
int num;
char str[40];
scanf("%d",&num);
gets(str);
return 0;
}
It seems that the scanf of an integer is impacting on the reading of the string with gets. I think that we could deal with this by using the fflush (stdin), but this is not in the ANSI C standard.
I would like to know if there is some standard way to deal with this in ANSI C.