Sorry for OT, but, this library makes me shudder.
Most horrible thing:
typedef char *string
. This gives the illusion of an actual
string
type, of which you'd assume it would hold a string value, although it still just holds a pointer(!) to an array of characters.
IMHO: Never ever hide a pointer behind a typedef.
And then, this
get_string()
function, well … best thing you can say about it is that it doesn't seem to have critical bugs. But why is it setting output non-buffered, and why does it call
realloc()
for each and every character entered, and WHY do you have to keep every string on the heap until the end of the program, etc…?
I don't know that course, maybe it isn't bad after all, but these fishy things in the library kind of disturb me.
So, the goal of the library simply is to "solve" the problem of user input before you understand how the I/O streams actually work in C. Maybe that's not the worst idea; it's better than some other courses just teaching to get user input with
scanf()
(which is
really a recipe for shooting yourself in the foot). But sooner or later (IMHO better sooner) you should understand how to do these things with standard C. For anyone interested, I wrote a few words on the topic a few years ago:
http://sekrit.de/webdocs/c/beginners-guide-away-from-scanf.html