这是下面的代码。我在编译过程中不断收到很多错误,错误:取消引用指向不完整类型的指针 X1->数据 = X1->数据 + Y1->数据;请帮忙。代码非常简单,只有 6 种情况。基本上,我有两个寄存器,X 和 Y,以及一个保存命令和值的多维数组(1000 个内存位置)。因此,当用户键入命令 101 时,它会转到函数"First",因此它是寄存器 X,并键入寄存器 X 的值,数组内存将此值保存在位置 [1][1],并将命令保存在位置 [1][0]。102 用于寄存器 Y。
#include<stdlib.h>
#include<stdio.h>
#define SIZE 1000
int first(int *counter, struct registers* X1, int m[][2])
{
int value;
printf("Enter the value for the Xn");
scanf("%d", &value);
X1->data = value;
m[*counter][0] = 101;
m[*counter][1] = X1->data;
*counter = *counter++;
return 0;
}
int second(int *counter, struct registers* Y1, int m[][2])
{
int value;
printf("Enter the value for the Yn");
scanf("%d", &value);
Y1->data = value;
m[*counter][0] = 101;
m[*counter][1] = Y1->data;
*counter = *counter++;
return 0;
}
int main()
{
int memory[SIZE][2];
int count = 0;
int choice;
struct registers
{
int data;
} registerX, registerY;
printf("Enter the instruction number:n");
scanf("%d", &choice);
switch(choice)
{
case 101:
first(&count, ®isterX, memory);
case 102:
second(&count, ®isterY, memory);
default:
printf("invalid code, please try againn");
}
}
struct registers
{
int data;
} . . . . .
这是main()
的本地。在全局范围内定义它。