我正在为一款名为MTG(魔术聚会)的游戏制作小型毒药计数器,并且遇到了一些无法让我编译的问题,任何人都可以帮忙吗?抱歉,如果它们很简单,我是C的新手。
#include <stdio.h>
#include <stdlib.h>
int life = 20;
int poison = 0;
int amount;
char pn;
char lp;
int main(int argc, char* argv[]) {
while(1){
system("clear");
printf("Life:%d\nPoison Counters:%d\n\n\n", life, poison);
printf("\n\n<Life or Poison>(l/p) <positive or negative>(+/-) <amount>(#)\n\n\n>>>");
scanf("\n\n%c %c %d", &lp, &pn, &amount);
if(lp == 'l'){
if(pn == '+'){
life = life + amount;
}
else{
life = life - amount;
}
}else if(lp == 'p'){
if(pn == '+'){
poison = poison + amount;
}
else{
poison = poison - amount;
}
}else if(lp == 'q'){
break;
}
}
}
}
return 0;
}
这就是Terminal告诉我的...
mtglife.c:36:2: error: expected identifier or ‘(’ before ‘}’ token
mtglife.c:37:1: error: expected identifier or ‘(’ before ‘return’
mtglife.c:38:1: error: expected identifier or ‘(’ before ‘}’ token
您尚未正确关闭主要功能。
#include <stdio.h>
#include <stdlib.h>
int life = 20;
int poison = 0;
int amount;
char pn;
char lp;
int main(int argc, char* argv[]) {
while(1){
system("clear");
printf("Life:%d\nPoison Counters:%d\n\n\n", life, poison);
printf("\n\n<Life or Poison>(l/p) <positive or negative>(+/-) <amount>(#)\n\n\n>>>");
scanf("\n\n%c %c %d", &lp, &pn, &amount);
if(lp == 'l'){
if(pn == '+'){
life = life + amount;
}
else{
life = life - amount;
}
}else if(lp == 'p'){
if(pn == '+'){
poison = poison + amount;
}
else{
poison = poison - amount;
}
}else if(lp == 'q'){
break;
}
}
return 0;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句