In article <11**********************@l77g2000hsb.googlegroups .com>,
nick048 <ni*************@moonsoft.itwrote:
>I have founded a problem in my program; it is in this code:
>i=0;
charRecv = recv(nSocketDesc, &c, 1, 0);
while (c !='\n')
{
mystring[i++]=c;
charRecv = recv(nSocketDesc, &c, 1, 0);
} // End while (c !='\n')
mystring[i]='\0';
>I need that while ends when the client press enter key.
But don't happen therefore.Sure, I mistake the condition in "while".
Please, someone can help me?
recv is not part of standard C, so as far as this newsgroup is
concerned, we don't know what it does. You should talk to people
who deal with whichever operating system extension is providing
recv() to your program.
In particular, since we don't know what recv() does, we don't
know that when the user presses the enter key that \n is the
character that is sent. It is plausible that when the
user presses the enter key, that \r is sent instead, or some
multi-character code that represents the enter key.
Glacing at the program, I also see a different possibility: namely,
that there might be input buffering on the side of whatever is
providing data to the recv(), so when the user is pressing
the enter key, the data is not necessarily transmitted to the
far end.
A typical way to debug a problem such as this would be to
print out the value of c after the recv(), in a couple of different
formats, so that you can see what value is getting to you and
with what timing.
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson