reprompt math question on C^d
This commit is contained in:
16
msh.c
16
msh.c
@@ -316,10 +316,15 @@ int mathTest() {
|
||||
#ifndef RELEASEBUILD
|
||||
printf("Answer: %ld\n", numSolution);
|
||||
#endif
|
||||
printf("%d %c %d = ", num1, mathOperation[randProblem], num2);
|
||||
numLine = readline("");
|
||||
if (numLine != NULL && strlen(numLine) > 0) {
|
||||
sscanf(numLine, "%ld", &numAnswer);
|
||||
while(numLine == NULL) {
|
||||
printf("%d %c %d = ", num1, mathOperation[randProblem], num2);
|
||||
numLine = readline("");
|
||||
|
||||
if (numLine != NULL && strlen(numLine) > 0) {
|
||||
sscanf(numLine, "%ld", &numAnswer);
|
||||
}
|
||||
|
||||
free(numLine);
|
||||
}
|
||||
|
||||
if (numSolution != numAnswer) { // If wrong answer
|
||||
@@ -337,7 +342,6 @@ int mathTest() {
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
free(numLine);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -370,6 +374,8 @@ void startShell() {
|
||||
}
|
||||
free(line);
|
||||
}
|
||||
printf("Exiting Shell\n");
|
||||
sleep(2);
|
||||
free(prompt);
|
||||
prompt = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user