C 错误:二进制+;(有(';int(*)和(';int(*)和(';)

C 错误:二进制+;(有(';int(*)和(';int(*)和(';),c,C,我正在创建下面的代码,从学生使用消极应对策略和与低自我形象相关陈述的一致性推断学生的压力水平。以下是我的代码,粗体是我遇到问题的部分: void statements (void); void printweightsstatements(void); void coping (void); void printweightscoping(void); void advice (); int cumweightstatement(); int cumweightcoping(); vo

我正在创建下面的代码,从学生使用消极应对策略和与低自我形象相关陈述的一致性推断学生的压力水平。以下是我的代码,粗体是我遇到问题的部分:

void statements (void);
    void printweightsstatements(void);
void coping (void);
void printweightscoping(void);
void advice ();
int cumweightstatement();
int cumweightcoping();

void main()
{
 statements ();
 coping ();
**if (int cumweightstatement + int cumweightcoping>=20)** 

 printf ("You are very stressed and at a high risk for depression. Please 
see a doctor or psychiaqtrist as soon as possible\n");
 else if (cumweightstatement + cumweightcoping>=15 && int cumweightstatement + int cumweightcoping<20)
printf ("You are quite stressed and at a moderate risk for depression. Please see your school guidance counselor\n");
else if (cumweightstatement + cumweightcoping<=14)
printf ("You are mildly stressed and at a low risk for depression, but you could still benefit from using positive coping strategies\n")
}

void printweightsstatements()
{
 printf("1:Strongly disagree\n");
 printf("2:Disagree\n");
 printf("3:Neither agree nor disagree\n");
 printf("4:Agree\n");
printf("5:Strongly agree\n");

}


void statements(void)

{
 int weight1;
 int weight2;
 int weight3;
 int weight4;

 printf ("How much do you agree with the following statements?\n");

 printf ("Statement 1: I have trouble concentrating on my homework for 1 hour straight\n");
 printweightsstatements;
 printf("1:Strongly disagree\n");
 printf("2:Disagree\n");
 printf("3:Neither agree nor disagree\n");
 printf("4:Agree\n");
 printf("5:Strongly agree\n");

printf ("Statement 2: I do not have much control over events in my life\n");
printweightsstatements;
printf("1:Strongly disagree\n");
printf("2:Disagree\n");
printf("3:Neither agree nor disagree\n");
printf("4:Agree\n");
printf("5:Strongly agree\n");
scanf("%d", &weight2);
printf ("Statement 3: During this school year, I have been stressed a lot\n");
printweightsstatements;
printf("1:Strongly disagree\n");
printf("2:Disagree\n");
printf("3:Neither agree nor disagree\n");
printf("4:Agree\n");
printf("5:Strongly agree\n");
scanf("%d", &weight3);
printf ("Statement 4: Although I try very hard, there is always some schoolwork too difficult for me\n");
printf("1:Strongly disagree\n");
printf("2:Disagree\n");
printf("3:Neither agree nor disagree\n");
printf("4:Agree\n");
printf("5:Strongly agree\n");
scanf("%d", &weight4);
printweightsstatements;

int cumweightstatement=weight1+weight2+weight3+weight4;
}


void coping (void);
{
  int weight1;
  int weight2;
  int weight3;
  int weight4;
  int weight5;

printf ("How often do you use each of the following coping strategies?\n");
printf ("Strategy 1: Negative self-talk (for example, I can’t do this,this is too hard for me, I’ll never get good at this)\n");
printweightscoping;
scanf("%d", &weight1);
printf ("Strategy 2: Overusing Internet/social media/phone for non-school-related activities (over 1 hour/day)\n");
printweightscoping;
scanf("%d", &weight2);
printf ("Strategy 3: Extended sleep or naps (above 8-9 hours of regular sleep)\n");
printweightscoping;
scanf("%d", &weight3);
printf ("Strategy 4:Procrastination or avoiding the task (leaving your schoolwork to the last minute, or not doing it at all)\n");
printweightscoping;
scanf("%d", &weight4);
printf ("Strategy 5:Denial (ignoring your problems and keep doing things the same way)\n");
printweightscoping;
scanf("%d", &weight5);
int cumweightcoping=weight1+weight2+weight3+weight4;
}

void printweightscoping(void);
{
 printf("1:Never\n");
 printf("2:Rarely(less than weekly) \n");
 printf("3:Sometimes(once a week)\n");
 printf("4:Often (several times a week)\n");
 printf("5:Always (about daily")
}

a';'在这条线的尽头不见了

    printf ("You are mildly stressed and at a low risk for depression, but you could still benefit from using positive coping strategies\n")
正如在评论中所说,你在某些行中有一些奇怪的声明

    else if (cumweightstatement + cumweightcoping>=15 && int cumweightstatement + int cumweightcoping<20)
但您将cumweightstatement和cumweightcoping声明为函数,而不是简单的变量

    int cumweightstatement();
    int cumweightcoping();
函数的名称是它在内存中的地址,这解释了为什么编译器抱怨添加了一些指针(二进制+(有'int(*)()()'和'int(*)()()')的操作数无效)

编辑: 代码中有很多错误,在声明为函数的变量之间存在混淆:
int-cumweightstatement();
应该是
int-cumweightstatement;
以及一些未正确执行的函数调用,如
printweightsstatements;
应该是
printweightsstatements();

在函数外部声明变量使其成为全局变量:您可以从文件中的任何函数访问它。 在函数中声明变量会使其成为区域设置:您无法将其超出其范围。 i、 例如:当您声明时,例如在
无效声明(void)
中:

声明一个区域设置变量
cumweightstatement
,并影响每个权重的总和。 但是一旦你退出这个功能,你就会失去它

从您拥有的代码开始,最简单的方法是使用globale变量,您可能会尝试使用该声明

    int cumweightstatement();
但是,这再次创建了一个函数,而不是一个globale变量


此链接将为您提供一些基础来声明函数和locale/globale变量

您的
int
应该是
(int)
。第一个是类型名称(您不能在可执行语句中使用),第二个是类型强制转换。您不需要强制转换,因为函数已经返回
int
。但是,您确实需要在函数名后添加
()
,以进行函数调用。如果(int-cumweightstatement+int-cumweightscoping>=20),您将如何处理
?该语句与正确的C代码相差甚远。如果您试图将它们作为函数调用,那么如何调用
printf()
否则如果(cumweightstatement+cumweightscoping>=15&&int-cumweightstatement+int-cumweightscoping您应该编辑您的代码来提供-进行一些清理,但我注意到,
void printwowtscoping(void);{
如果这应该是函数,那么它应该像
void printwowtscoping(){…}
void main()
不正确,请参见:。另请参见:我尝试过,但它说“'cumweightstatement'未声明(此函数首次使用)”我的函数printweightscoping不起作用,尽管PrintWeightStatements是:void PrintWeightStatements(){printf(“1:强烈不同意”\n”);printf(“2:不同意”\n”);printf(“3:既不同意也不不反对\n”);printf(“4:同意\n”);printf(“5:强烈同意”;)和void printweightsscoping(){printf(“1:从不”\n”);printf(“2:很少(少于每周)\n”);printf(“3:有时(每周一次)\n”);printf(“4:经常(每周几次”);printf(“5:总是(大约每天);”我已经改变了声明cumweightstatement和CumWeightComping的方式,但这没有什么区别
    int cumweightstatement();
    int cumweightcoping();
    int cumweightstatement=weight1+weight2+weight3+weight4;
    int cumweightstatement();