This code will work fine if I use fgets()
first and then scanf()
,but not the other way around. Why?
#include<stdio.h>
#include<string.h>
int main(void)
{
int n;
char a[100];
scanf("%d",&n); //accept a number from user
fgets(a,100*sizeof(char),stdin); //accept a string from user
printf("%d\n",2*n);
printf("%s\n",a);
return 0;
}