I am learning C using C for dummies 2nd Edition. I'm using codeblocks 10.05 with mingw (GCC) on Windows 7 Ultimate (64bit).
When I compile and run the code below on Windows XP everything works as expected and I can input from the keyboard fine and the loop does not exist until I press ~ followed by Return.
Unfortunately in Windows 7 running the code as a normal user or as administrator it, appears to, just totally ignore the while loop, prints the other messages to screen and exits the program.
Is there a problem with this code on Windows 7?
Code:
#include <stdio.h>
int main()
{
char ch;
puts("Start typing");
puts("Press ~ then Enter to stop");
while(ch!='~')
{
ch=getchar();
}
printf("Thanks!\n");
return(0);
}
Thanks in advance.