This code is pretty bad:
Code:
char holder;
printf("hello");
getch(holder);
- getch() is non-standard.
- If you really want to use it, and your compiler has it, you need another header file (<conio.h> for Dev-C++).
- getch() takes no arguments -- it returns the value. So you can just discard it (and you don't need holder).
- Even if getch() did take an argument as the place to store the value, you would need to pass it as a pointer to get the value.
This code's okay:
Code:
int main( .., ...){
//code
getchar();
return 0;
}
getchar() is in <stdio.h>, which most programs include. But that won't work if there's more in the input buffer than just a '\n'. (And // comments are C99 . . . . )
ssharish2005's code is the best. Use it instead of the other stuff.
All of this is covered in Dave's FAQ link.