I would like to know if there is a better method to read from stdin than the current one I have.
This is what I currently use:
But the problem is, some very long strings seems to get truncated from time to time and I don't receive the entire string being sent.
Can someone please help me identify what could be the problem?
A bit of background:
My program listens to input on stdin. It is called by Microsoft telnet server because MS telnet server is responsible for listening to incoming telnet connections. So everytime something is picked up by MS telnet server, MS telnet server then calls my program which receives the string as stdin. So either my code to read from stdin is not very well written, or could it be that there is a problem with MS telnet server passing me a truncated string?
I need help on this urgently.
Thanks very much.
string str = "";
CStdStringA bufs = "";
while(((ch = getchar()) != '\r'))
if(ch == '\n')
bufs.append(1, (char) ch);
str = bufs;
bufs = ""; //Reset the string to empty
.....//Code to handle the str.....