我的代码在CLion中完全正常运行,但我在repl.it中收到错误

时间:2018-06-05 23:41:54

标签: c repl.it

有人可以帮帮我吗?我是C编程的新手,我在repl.it中遇到一个编译问题,当我在CLion中运行我的代码时,它没有出现。

错误是: 退出状态-1

main.c:1:1:错误:预期的标识符或'('在数字常量之前  12  ^〜

/*
 * Description: This is a multiplication problem generator, for children.
 * Created By: Michael Isenhour
 * Date Written: June 6th, 2018
 */
#include <stdio.h>
#include <stdlib.h>

int generateRandomNumber();
void askQuestion(int, int);

int main(void) {
    srand(1712);
    int counter = 0;
    while (counter < 10) {
        int randomlyGeneratedFirstNumber = generateRandomNumber();
        int randomlyGeneratedSecondNumber = generateRandomNumber();
        int answer = randomlyGeneratedFirstNumber * randomlyGeneratedSecondNumber;
        int userAnswer;
        askQuestion(randomlyGeneratedFirstNumber, randomlyGeneratedSecondNumber);
        scanf("%d", &userAnswer);

        while (userAnswer != answer) {
            puts("No, Please try again");
            askQuestion(randomlyGeneratedFirstNumber, randomlyGeneratedSecondNumber);
            scanf("%d", &userAnswer);
        }

        puts("Very Good");
        counter++;

    }
    return 0;
}

int generateRandomNumber() {
    int result;
    result = 1 + (rand() % 9);
    return result;
}

void askQuestion(int firstNumber, int secondNumber) {
    printf("How much is %d times %d\n", firstNumber, secondNumber);
}

1 个答案:

答案 0 :(得分:0)

来自Repl.it的Yev,你给我的代码在-uUSERNAME中起作用 https://repl.it/@yevb/CarpalCarefulOffices