0

当我去编译下面的程序时,我得到了这个错误,我不知道为什么。

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");        
}
4

2 回答 2

3

应该

scanf("%lld", &d); //not scanf("%lld" &d);
于 2012-09-14T00:43:19.107 回答
2

你忘记了一个逗号scanf("%lld" &d);。这导致它将参数解释scanf为某些字符与数字 BITAND 的结果。

将其更改为:

scanf("%lld", &d);
于 2012-09-14T00:43:18.107 回答