[英]subscripted value is neither array nor pointer
I am writing a C program in which I am using an array of pipe for IPC.I am getting error "subscripted value is neither array nor pointer".Can any one tell me where did I do mistake? 我正在编写一个C程序,其中正在使用IPC管道数组。我收到错误消息“下标值既不是数组也不是指针”。有人可以告诉我我在哪里出错了吗?
here is the code where I get error: 这是我得到错误的代码:
int p[100][2];
//in for loop
pipe(p[i-1]);
//in child process
close(p[i-1][0]);
write(p[i-1][1], out, sizeof(NODE));
//in parent process
close(p[j][1]);
ead(p[j][0], tmp, sizeof(NODE));
Pro tip: When resolving build errors in C don't pick any random error in the list and try to fix it. 专家提示:解决C语言中的构建错误时,请不要在列表中选择任何随机错误并尝试对其进行修复。 Start with the very first error generated as it is likely the root cause of many of the others that follow. 从产生的第一个错误开始,因为这很可能是随之而来的许多其他错误的根本原因。
You must have a syntax error somewhere else in your code that is throwing off the declaration of int p[100][2]
so that the identifier p
is not appropriately parsed as a 2-dimensional array of type int
allocated on the stack (or statically allocated as a global variable ... you didn't mention where it was declared.). 您必须在代码的其他地方出现语法错误,该语法错误会抛弃int p[100][2]
的声明,以便标识符p
不能正确地解析为在堆栈上分配的int
类型的二维数组(或静态分配为全局变量...您没有提到它的声明位置。) Since the identifier is not parsed correctly, it then also throws off every other use of p
in your code. 由于未正确解析标识符,因此它还会引发代码中其他所有p
使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.