2013-01-15 53 views
-1

我使用Visual Studio中得到以下錯誤:錯誤:預期的標識符

41智能感知:預期的標識符

我不知道這是什麼想說的任何幫助將不勝感激! :d

下面是程序:

#include <stdio.h> 
#include <math.h> 

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

    //Ask for numbers of days as long as input is not between 28 and 31 

    do 
    { 
    printf("How may days are in your month?\n"); 
    d = GetInt(); 
    } 
    while (d<28 || d>31); 


    //Ask for numbers of pennies for day 1 as long as input is negative 



    printf("How many pennies do you have"); 
    do 
    { 
     p = GetInt(); 
    } 
    while ("p<0"); 


    //Sum up the pennies, pennies = (pennies*2)*2..*2 

    int 1; 
    for (i=0; i<= d-1; i++); 
     { 

      p=p*pow(2,i); 
     }  
    printf("%lld\n", p); 
    return 0; 
}` 

回答

5
int 1; 
for (i=0; i<= d-1; i++); 

這裏有int 1;所以編譯器正在尋找一個變量名,如int x = 1; 現在for循環,從終點

刪除 ;

main裏面你有前兩行是

long long d; 
long long p; 

這裏long是一種類型,所以更改這些行

long d; 
long p; 

在年底你的文件,我看到}',這裏刪除'字符

此外,我可以看到你有while ("p<0");作爲條件,這裏"p<0"是一個字符串,你可能想把它改爲p<0

+0

好的,非常感謝! :d –

2

你也可能想與

while(p<0); 

(不帶引號),以取代

while ("p<0");