0
votes

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?

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));
2
Uh, one would kinda need to know the types of your variables to say where the problem is. (Though, actually, I suppose it would have to be "p", since that's the only variable being indexed.) - Hot Licks
p is the file array of pipes each p has two file descriptors p[0] and p[1] - het
and these all are lines with error - het
You need to provide actual code. You likely have a problem somewhere else. This certainly isn't the actual code you are trying to build. - Dave Rager

2 Answers

3
votes

Pro tip: When resolving build errors in C don't pick any random error in the list and try to fix it. Start with the very first error generated as it is likely the root cause of many of the others that follow.

1
votes

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.). Since the identifier is not parsed correctly, it then also throws off every other use of p in your code.