Hi,
I am new to programming and currently working on a project for my intro to programming class. I am trying to get a "Press any key to continue..." prompt but so far have only been able to get it to do so if you input an actual character. I do not want to use system("PAUSE") tho I know that would work. Any way to replicate the system("PAUSE") without actually using it?
Thanks,
Here is what I have thus far:
}
printf("\n Do you want to perform another calculation? (y/n)> \n\n");
while((c = getchar()) != '\n' && c != EOF);
scanf(" %c",&again);
{
if(again != 'y' || again != 'Y' || again != 'n' || again !='N'){
printf("\n\n#######Invalid Selection #######\n\n");
printf("(Error)\n\n");
}
else{
break;
}
while((getchar() == EOF));
printf("\nPess any key to continue...\n");
scanf(" %c",&id);
}
}
while (again == 'y' || again == 'Y');
return(0);
}
This is what I use for Pause:
void Pause(void)
{
printf("\n%s\n","Press any key to continue . . .");
_getch();
}
James
http://forum.pellesc.de/index.php?topic=2793.0
Have fun :)
You may try the following, cross-platform macro...
/* cross-platform alternative to Windows system("pause") */
#define pressENTER() \
do{ \
int mYcHAr; \
printf( "Press ENTER to continue..." ); \
fflush(stdout); \
while ( (mYcHAr=getchar()) != '\n' && EOF != mYcHAr ) \
; \
}while(0)