c - 程序没有显示错误,但无法编译。你能帮我解决我需要做的事情吗

标签 c compiler-errors

程序没有显示错误,但无法编译。您能帮我解决这个问题吗?

int main(void) {
    printf("\n*************************************************************\n");
    printf("\n*************************************************************\n");
    printf("\n******** Program find the solution to which car you *********\n"); 
    printf("\n******* could still earn if you received A's for the ********\n"); 
    printf("\n********* remainder of your undergraduate classes. **********\n");
    printf("\n*************************************************************\n");
    printf("\n*************************************************************\n");
    printf("\n  You will be asked to enter your current GPA with at most 3 \n");
    printf("\n  Decimal places and the number of credit hours that the GPA \n");
    printf("\n       Was based on, which should be a positive number.      \n");
    printf("\n  And the honors you qualify for will be displayed to screen.\n");
    printf("\n*************************************************************\n");
    printf("\n*************************************************************\n");

    printf("\nPlease enter your current GPA with at most 3 decimal places.\n");
    printf("\nFor example, for a GPA of 2.3333333333, enter 2.333\n");
    printf("\nThis GPA should fall between 0 and 4.0 --> ");
    scanf("%d, &numb1\n");
    printf("\n*************************************************************\n");

    printf("\nPlease enter the number of credit hours that this GPA was based");
    printf("\n on. This should be a positive integer\n");
    printf("\nFor example, for twelve credit hours, simple enter 12.\n");
    printf("\n-->");
    scanf("%d, &numb2");
    printf("***************************************************************\n");
}

最佳答案

由于双引号的放置位置,您将向 scanf 传递一个参数。

应该是:scanf("%f", &numb1);scanf("%d", &numb2);

请注意,numb1%f,因为它是 float ,numb2%d(对于整数)。

此外,您从未声明过变量 numb1numb2,因此您还需要: float numb1; int numb2; 位于函数顶部。

关于c - 程序没有显示错误,但无法编译。你能帮我解决我需要做的事情吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52320536/

相关文章:

android - 无法编译值文件

c++ - 编译为 C++ 但不是 C(错误 : lvalue required as unary '&' operand)

scala - 用Scala,Apache Spark编写的编译错误保存模型

c - while 循环会检查每个条件吗?

c - 内联递增数组索引

c++ - iphlpapi/ifdef.h

compiler-errors - 药剂: Why do I get “undefined function” error?

c - 为什么长时间运行的程序总是要收割它们的僵尸 child ?

c - 我正在开发自己的多行输入功能,我想终止时无法终止

c++ - AVX中的6元素 double vector 矩阵 vector 相乘