I can't tell why this piece of code wont work, but another one which I wrote does because they look exactly the same to me. Please tell me if you can see what the difference is because I cannot. I tried using the code snippet thing, but it doesn't let you copy/paste and I'm not really interested in typing both out again right now.
First one:
#include <stdio.h>
#include <stdlib.h>
main()
{
char cYesNo = '\0';
int iResp1 = 0;
int iResp2 = 0;
int iResp3 = 0;
int iElapsedTime = 0;
int iCurrentTime = 0;
int iRandomNum = 0;
int i1 = 0;
int i2 = 0;
int i3 = 0;
int iCounter = 0;
int x = 0;
srand(time(NULL));
printf("\nPlay a game of Concentration? (y or n): ");
scanf("%c", &cYesNo);
if(cYesNo == 'Y' || cYesNo == 'y') {
i1 = rand() % 100;
i2 = rand() % 100;
i3 = rand() % 100;
printf("\nConcentrate on the numbers: %d %d %d", i1, i2, i3);
iCurrentTime = time(NULL);
do{
iElapsedTime = time(NULL);
} while ( (iElapsedTime - iCurrentTime) < 3);
for(x=0;x<25;x++); {
printf("\n\n\n");
}//end for
printf("Enter each number separated with a space: ");
scanf("%d%d%d", &iResp1, &iResp2, &iResp3);
if(i1 == iResp1 && i2 == iResp2 && i3 == iResp3)
printf("\nCongratulations!!!");
else
printf("\nSorry you didn't get it correct");
}//end if
}//end main
Second one:
int x = 0;
char cYesNo = '\0';
int iResponse1 = 0;
int iResponse2 = 0;
int iResponse3 = 0;
int iElapsedTime = 0;
int iCurrentTime = 0;
int iRandomNumber = 0;
int i1 = 0;
int i2 = 0;
int i3 = 0;
srand(time(NULL));
printf("\nPlay a game of Concentration?\n");
printf("\nYes or No (Y or N//y or n)\n");
scanf("%c", &cYesNo);
if (cYesNo == 'Y' || cYesNo == 'y') {
i1 = rand() % 100;
i2 = rand() % 100;
i3 = rand() % 100;
printf("\nConcentrate on the numbers as hard as you can!!!\n");
printf("\n %d \t %d \t %d \n", i1, i2, i3);
iCurrentTime = time(NULL);
do {
iElapsedTime = time(NULL);
} while ( (iElapsedTime - iCurrentTime) < 3); //End do-while loop
for(x = 0; x < 30; x ++) {
printf("\n");
}
printf("\nEnter the three numbers you saw a minute ago separated by a space each.\n");
scanf("%d %d %d", &iResponse1, &iResponse2, &iResponse3);
if(i1 == iResponse1 && i2 == iResponse2 && i3 == iResponse3)
printf("\nCongratulations\n");
else {
printf("\nSorry you chose wrong\n");
printf("\nThe correct numbers were:%d %d %d\n", i1, i2, i3);
}//end else
}//end if
}//end main
The top one doesn't pause correctly, but the bottom one will. If you can see what I missed that would be great.