The getstr function is dodgy. scanf() is looking to take in just one char, but the user is trying to enter a string. And scanf() has to have an enter key to assign a value (buffered input).
fgets() is the function that immediately comes to mind for string entry. Overflowing the buffer array is no problem, and only one enter key needs to be pressed for each line. Also, the enter key is removed from the keyboard buffer with fgets(), and the end of string marker char is automatically added for you, if you just leave a space for it in the buffer.
fgets() is a very good standard C way, to get a line of char's. You need a char buffer, where fgets() will put the chars, and you need some little bit of code:
char buffer; //make it bigger than any line should be
fgets(buffer, sizeof(buffer), stdin);
sizeof() just tells fgets() it can get UP TO 100 char's and no more, from the file stream named stdin. In practice, it should get no more than 98 char's from the user, because it will need two spaces: one for the newline when the user hits the enter key, and one for the end of string marker char: '\0' (which is a zero in value).
stdin is a file that C opens every time it runs a program - along with stdout. stdin is the keyboard, and stdout is your monitor.
Good to have u as my friend....I am interested n doin a project in c...
I have finished half of t...my project s ubuntu terminal...
I have to include a feature in which if we press up arrow t has to go to the previous commands....Can you give me a idea on that...