forked from Spencer/math_shell
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
|
#ifndef RELEASEBUILD
|
||||||
printf("Answer: %ld\n", numSolution);
|
printf("Answer: %ld\n", numSolution);
|
||||||
#endif
|
#endif
|
||||||
printf("%d %c %d = ", num1, mathOperation[randProblem], num2);
|
while(numLine == NULL) {
|
||||||
numLine = readline("");
|
printf("%d %c %d = ", num1, mathOperation[randProblem], num2);
|
||||||
if (numLine != NULL && strlen(numLine) > 0) {
|
numLine = readline("");
|
||||||
sscanf(numLine, "%ld", &numAnswer);
|
|
||||||
|
if (numLine != NULL && strlen(numLine) > 0) {
|
||||||
|
sscanf(numLine, "%ld", &numAnswer);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(numLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numSolution != numAnswer) { // If wrong answer
|
if (numSolution != numAnswer) { // If wrong answer
|
||||||
@@ -337,7 +342,6 @@ int mathTest() {
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
free(numLine);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,6 +374,8 @@ void startShell() {
|
|||||||
}
|
}
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
printf("Exiting Shell\n");
|
||||||
|
sleep(2);
|
||||||
free(prompt);
|
free(prompt);
|
||||||
prompt = NULL;
|
prompt = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user