I have a program (in C) that runs in the command line, and I am looking to have it accept strings of arbitrary length from users. If I were programming in C++, I would probably use the getline() function in the string library, but I can’t seem to find a C equivalent. Do I just need to read characters in blocks of X length, and if the string goes over X length, make a new bigger block and copy data over to the new block?
Share
You can use
fgetswithsscanf.Note that
getlineis now present in the current POSIX:2008 standard.http://pubs.opengroup.org/onlinepubs/9699919799/functions/getline.html