I want to read a string from the console.
Using scanf or fgets however, it seems to me that it’s only possible to read a string of a fixed maximum size. Even worse, there seems to be no way of checking how many characters were entered in case the user enters too much (in that case I could simply realloc the array in order for the string to fit into the array).
I read that I’m supposed to read one character at a time in the answer to this question, however I don’t know how to read one character at a time without having the user press enter after each character.
How can I do it?
Try running this..
then check out the man page for getchar() to see what’s really at hand.