c - scanf 调用中类型的无效操作数

标签 c

当我去编译下面的程序时出现这个错误,我不明白为什么。

39:19: error: invalid operands of types ‘const char [5]’ and ‘long long int’ to binary ‘operator&’

这是代码。

int
main(void)
{
    long long d, p; 

    // Ask for number for the numbers of  days as long as input is between 28 and 31
    do  
    {
       printf("How many days are in your month?\n");
       scanf("%lld" &d);    // This is the line with the error
    }   
    while (d<28 || d>31);

    // Ask user for number of pennies for day 1 as long as input is not negative
    printf("How many Pennies do you have?\n");
    do
    {
        scanf("%lld", &p);    
    }
    while (p<0);

    //sum up the pennies
    int i;
    for (int i=0; i<=d-1; i++);
    {
        p = (p * 2);
    }

    // Format and print the total  (currently * instead of / for troube-shooting)
    double total;
    total = (p * 100);
    printf("Your ending amount it $%.2f.\n, total");        
}

最佳答案

应该是

scanf("%lld", &d); //not scanf("%lld" &d);

关于c - scanf 调用中类型的无效操作数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12416720/

相关文章:

c - 当所有值都有效时如何终止可变长度数组?

android - 尝试编译 native 代码时出现权限问题

c++ - 无法在 Linux 上找到 SDL2_gfx 库

c - 通过void修改任何数据指针是否合法**

c - 多项式插值中的段错误

c - 为什么不能使用 memcmp() 函数进行浮点类型比较?

c++ - 对大枚举值的表示是否有任何保证?

java - FFmpeg 命令帮助和文档指针

c++ - 启动时多线程?

c - C 中的字符串数组