I’m new with QNX 6. I want to be able to read in a string of characters from the keyboard in IDE using the fgets() function, however, when I’m running the program in the IDE, the presence of the fgets() itself causes nothing to be outputted to the console view.
#define MAXBUF 20
fgets(buff,MAXBUF,stdin); //if this line is included, nothing shows up
printf("You typed %c\n",ch);
How can I read keyboard input in an IDE C Project?
the printf is a buffered output function. Either terminated it with a /n or call fflush(stdout) that will force the buffer to be flushed.
Without the fgets the → would get output to screen at the same time as the second printf.
You guys may be missing the point. Where does stdin point when a program is launched from the IDE? I suspect somewhere funky.
If you run your program from the command line, it will probably work as you expect.
It’s odd that IDE doesn’t allow you to use stdin. I’ll just use command line then, thanx.
You can do it, but you have to to a setvbuf() to turn off buffering as the IDE doesn’t attach you to a proper tty. This is in the release notes for the IDE.