使用一个非常简单的计算器程序,提示用户执行操作,然后提示两个整数来执行此操作。 程序应该在这些操作之后循环,除非用户输入字符’q’,此时程序应该退出。 #include int main (void) { char c; int number[2], num1, num2, result; double num1d, num2d, resultd; int done=1; while(done) { printf(“\t What sort of operation would you like to perform? \n \t Type + – * / accordingly. \n”); c = getchar(); printf(“\tplease enter a number \n”); scanf(“%d”,&number[0]); printf(“\tplease enter another number \n”); […]
我正在使用scanf() returns when it gets what is expects or when it doesn’t. What happens is it gets stuck in the scanf() returns when it gets what is expects or when it doesn’t. What happens is it gets stuck in the while()循环中。 据我所知test = scanf(“%d”, &testNum); 如果收到数字则返回1,否则返回0。 我的代码: #include int main(void) { while (1) { int […]