Hanging on fscanf of pipe

Pages: 12
> while ( select(1,&set,NULL,NULL,&tmo) == 1 )
You mucked up the first parameter of select.
The first parameter is the maximum descriptor in the set (+1), not the number of descriptors in the set.
All you're doing is waiting for stdin, and stdin isn't even in the set.

> unsigned char buf[1024]; // BUFSIZ
You had a perfectly good constant, and you replaced it with magic numbers.

> ret += (const char*)buf;
Perhaps
ret += string(buf,n);
https://www.cplusplus.com/reference/string/string/string/
Then you don't have to 'allow space for a \0' with yet another magic number.
Last edited on
Oof I knew I should have asked before touching anything :/

1) um. Uhh oops ok so I think I get it now ok... thank you I will change it back :P

2) ye I was just gonna try and figure out where BUFSIZ comes from before I use it because whenever I use something that I don’t know where it comes from then I’ll come back to the program later on to revamp or clean or whatever and I have to spend the next thirty min trying to figure out which headers I don’t need anymore, so yes I’m going to use it I just want to find it first XD

3) I.. didn’t notice that constructor type when I looked, thank you! :D
Ok so that string constructor didn’t work...
WORKS!!

thank you guys so much for helping me out I very much appreciate it :)
Last edited on
Registered users can post here. Sign in or register to post.
Pages: 12