Thank you guys. I have the program working now. I wrote a function that I'd like to use to accept user input, but I'd like to get an opinion of someone more experienced.
void gstring(char *string, int string_length)
fgets(buffer, BUFSIZ, stdin);
for(counter = 0; counter < string_length; counter++)
string[counter] = buffer[counter];
string[string_length - 1] = '\0';
So basically if I only want 20 characters to be read, it'll read just the 20.. but not leave anything standing around in stdin.
I would like to have a function that's universal to strings that use arrays to allocate the memory and strings that use malloc() or some other memory allocation function to allocate the memory.
like if I were to do the following...
how could I just get 80 characters or less without leaving anything in stdin?
string = malloc(80 * sizeof(char));
Thank you all again for reading this (long) post. I find all this "extra characters waiting in stdin" to be very troublesome and confusing.