------------------------------------------------------------------------- #include <stdio.h> int main() { int i, n; int ch; printf("This program prints a table of squares.\n"); printf("Enter number of entries in table: "); scanf("%d", &n); for (i = 1; i <= n; i++) { if( i == 25 ) { do { printf("Press enter to continue..."); ch = getchar(); } while (ch != '\n'); } printf("%10d%10d\n", i, i * i); } return 0; } ------------------------------------------------------------------------ Thanks. --ad4
Hi! I'm completely new at gnu c and I 've a problem with getchar() method.
My program is given below. first it asks for a number than it shows the
squared output which begins from 1 to that number. But after 24 output it
supposed to stop and show a message "Press enter to continue..." and when
pressed return key it should proceed with the calculation. My program shows
the squarred output fine but it doesn't stop after 24 And also I don't want
to use scanf. Can anyone please tell me where i am doing wrong?
- Problem with getchar method! DC A
- Re: Problem with getchar method! Ian Lance Taylor