The readln reads until the end of line (enter pressed) with spaces and everything,
I would like something like that but for ansi c (not c++ and need to be for linux and windows)
I know that I can make a function that reads every char until the enter pressed but If there is anything cooler it would be great =D
Thanks!
You can use scanf
with a scanset conversion something like this:
char buffer[256];
scanf("%255[^\n]", buffer);
another possibility is to use fgets
:
char buffer[256];
fgets(buffer, sizeof(buffer), stdin);
On Linux (and other POSIX-ish systems) you should probably also have a function named (surprise, surprise) readline
that's similar, but will allocate the space necessary for the incoming data.
From here there is fgets that does this.
Yes.
char * fgets ( char * str, int num, FILE * stream );
Are you looking for something like this.