我正在用 C 语言做一个项目,偶然发现了一些问题,希望你们能帮助我!该项目只是操纵用户通过标准输入创建的坐标点。我在下面包含了不同的文件及其功能;
//points.h
struct Point{
int x;
int y;
}
//reads points from stdinput into our points array
int pointReader(struct Point points[]);
///////////////
//points.c
void pointReader(struct Point points[]){
//points[] is originally empty array (filled with NULLS)
struct Point point;
char buffer[10];
printf("X Coordinate:");
fgets(buffer, 10, stdin);
point.x = (int)buffer;
printf("Y Coordinate:");
fgets(buffer, 10, stdin);
point.y = (int)buffer;
append(points, point);
}
static void append(struct Point points[], struct Point point){
int i;
for (i = 0; i < 10; i++){
if (points[i] == NULL){
points[i] = point;
}
编译后,我收到以下错误,我不太清楚为什么:
points.c:115:10: error: invalid storage class for function 'append'
points.c: In function 'append':
points.c:127:17: error: invalid operands to binary == (have 'struct Point' and 'void *')
points[]
另外,我可以像我试图做的那样轻松地在阵列周围“折腾”吗?
感谢您的任何评论!