At 3/3/2010 05:44 AM, you wrote:
>does anyone have idea how should new line charchter will be read by
>getch function...
>my code is give below, but it not working properly...
>
>
>char ch[100];
>while ( ch!='\n')
>{
> ch=getch();
> cout << "$";
>}
Well, first, you should be reading only a char, not an array of
chars. So ch should be char ch; not char ch[100];
Second, getch() is old and does not work well with C++. It goes back
to the DOS days. In DOS, a line ends with "\r\n" (0x0D 0x0A) but
getch() is probably converting the pair to \r. If you want to
continue using getch(), try checking for both \r and \n e.g.
while ( (ch != '\n') && (ch != '\r') ) {}
You didn't say what wasn't working. For more help, you are going to
need to explain your problem in more detail.
~Rick