If I need to write a program that reads a string (a person's name)
then print out the first five characters of the name, how can i do that?
for example:
johnny will output johnn
this is what I wrote
however, if the user inputs more than 5 characters, then the array for input will not be large enough to hold...Code:int main () { char input[5]; while (scanf("%s\n",input) != EOF) { printf("%s\n",input); } return 0; }
but at the same time, i can't restrict the number of characters that a user type in...
so, any hints?