I am using gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2 I am writing a very simple script to take string as input and print the same with the some custom message. Fi
This line
scanf("%d",&T);
reads the input until the first non-numeral is found, which is newline. Then fgets() reads that newline for its first input.
newline
fgets()
I suggest using fgets() to read the number too.
fgets(str,80,stdin); sscanf(str, "%d", &T);