Quote:
Originally posted by Hammer
I see it so fast 'cos I've practiced a lot and am experienced in these things, thats all. :)
The ASCII chart is available at the link I gave in my earlier post.
>while ((pass[num] = getch()) != 13)
I recognised this because getch() returns the ASCII value of the character it read in. Therefore, it is testing against an ASCII 13 (CR).
Now, about CR. One a Windows machine, the end of a line is denoted by the ENTER button. But underneath the hood, the OS sees this as a Carriage Return AND Line Feed (2 bytes together). These are 13 and 10, or in hex 0x0d and 0x0a. If you have a hex editor, open any text file, and look for these values to see what I mean.
On a Unix machine, end of line is denoted by only one byte, 10 (0x0a).
It is not good practice to hardcode these values in your source though. You should really use these equivalents:
\n
\r
I think now i finally understand. 13 can be replace by "\n" right?