In C, Strings are just array of char type of variables. So,
char myString[100]
This will be handled by the compiler as a string of 99 characters and the last one 'should' be null. Null in C is defined as '\0'. If you read the characters by using scanf, then it wont put the terminating character(\0) at the end. So, rather use fgets.
Suppose, you are reading a string of 50 characters using scanf, then you can terminate the end by using the following statement
myString[50] = '\0';
try the sample code
#include <stdio.h>
int main()
{
char myString[50];
fgets(myString, 49, stdin);
printf("%s\n",myString);
return 0;
}
That's the most convenient way to read a String and get an output iin C. fgets always puts the terminating character (\0) automatically at the end of the string.