getch()

hey guys i want to enter an array element with getch(), with followig statement


name[1][1]=getch();
cout<<name[1][1];
int x=name[1][1];
cout<<x;

it works well, when i press enter as my input, it returns an ASCII equivalent of 13.
when i enter the array elementwith get(), with foolowing statement

cin.get(name[1][1]);
cout<<name[1][1];
int x=name[1][1];
cout<<x;

it returns an ASCII equivalent of 10, (if i input enter). why this difference occurs??
actually i am new to programming and want to learn getch() completely.
Last edited on
The end of line is two characters on Windows, carrage return (13) then line feed (10). cin.get is stripping the line feed.

cin.get() converts <CR><LF> to <LF> to make it consistent with POSIX. For some reason, it doesn't do that with getch(), I don't know why.
Last edited on
Topic archived. No new replies allowed.