以下代码中出现错误。如果我删除“结构点p2 ...”,错误将消失。 p1以相同的方式组装并且可以正常工作,这里有什么问题?
#include <stdio.h>
struct point {
int x;
int y;
};
struct point makepoint(int x, int y)
{
struct point temp;
temp.x = x;
temp.y = y;
return temp;
}
struct point addpoint(struct point p1, struct point p2)
{
p1.x += p2.x;
p1.y += p2.y;
return p1;
}
void main()
{
struct point p1 = makepoint(5, 7);
printf("p1 = (%d, %d)\n", p1.x, p1.y);
struct point p2 = makepoint(2, 9);
printf("p2 = (%d, %d)\n", p2.x, p2.y);
}
#include <stdio.h>
#include <string.h>
struct arithmet {
char eval;
int first_num,sec_num;
};
/* function declaration */
void eval_value( struct arithmet *valyu );
int main( ) {
struct arithmet valyu1;
struct arithmet valyu2;
char oper;
int num1,num2;
oper=getch(); //gets(oper);
scanf("%d",&num1);
scanf("%d",&num1);
valyu1.first_num=num1;
valyu2.sec_num=num2;
valyu1.eval=oper;
eval_value(&num1);
eval_value(&num2);
eval_value(&per);
printBook( &Book1 );
printBook( &Book2 );
return 0;
}
void eval_value(struct arithmet *valyu)
{
valyu->first_num;
valyu->sec_num;
valyu->oper;
if(oper=='+')
{
printf("%d",addit(int a,int b));
}
if(oper=='-')
{
printf("%d",subtractit(int a,int b));
}
if(oper=='*')
{
printf("%d",multiplyit(int a,int b));
}
if(oper=='/')
{
printf("%d",divideit(int a,int b));
}
if(oper=='@')
{
printf("%d",intdivideit(int a,int b));
}
if(oper=='%')
{
printf("%d",remdivideit(int a,int b));
}
if(oper=='~')
{
printf("%d",exponeit(int a,int b));
}
}