我正在尝试在Xcode 5上编译这个简单的程序,我在下面的错误行中收到“thread 1:breakpoint 1.1”消息。有谁知道我怎么解决它?
这是我的代码:
#import <Foundation/Foundation.h>
int totalSavings(int listTotal);
int main(int argc, const char * argv[])
{
@autoreleasepool {
int itemEntry, itemEntry1, itemEntry2,
listTotal, calcSavings;
itemEntry = 320;
itemEntry1 = 218;
itemEntry2 = 59;
listTotal = itemEntry + itemEntry1 + itemEntry2;
calcSavings = totalSavings(listTotal); \\error line
NSLog(@"Total Planned Spending: %d \n Amount Saved: %d", listTotal,
calcSavings);
}
return 0;
}
int totalSavings(int listTotal)
{
int savingsTotal;
savingsTotal = 700 - listTotal;
return savingsTotal;
}
答案 0 :(得分:1)
在调用中包含int
类型的语法不正确。
错误的一行:
calcSavings = totalSavings(int listTotal);
固定线路:
calcSavings = totalSavings(listTotal);
错误消息是:
Untitled.m:16:36: error: expected expression
calcSavings = totalSavings(int listTotal); // error line
^
注意int
下的“^”,这清楚地表明了错误的位置。