0
error: expected ‘)’ before ‘[’ token error line is - void display(ptr[i]); 

this is the error which i get after compilation, what does it mean, i have written a simple program in C

2
  • check it as ptr=ptr[i]; void display(ptr); and inform is there same error? Commented Jan 25, 2011 at 6:05
  • 1
    Why did you remove the code ? Commented Jan 25, 2011 at 6:07

6 Answers 6

1

I can only imagine you are missing a ')' on the line above that line. But more source code would help in identifying the problem.

Sign up to request clarification or add additional context in comments.

1 Comment

Even having said that the snippet can see looks particularly dodgy.
0

Two Issues :

  • void display(ptr[i]);. You shouldn't include return type while calling the function. Return type should be collected and it is up to the caller to collect it. So, change void display(ptr[i]); to display(ptr[i]);
  • main should always return something.

Comments

0

You need to give more context, but it looks like you are making a forward declaration. If so, you need to provide a formal argument type. Right now it looks like you are supplying an "actual" argument.

Also, be sure you have a semicolon finishing the prior line. The lack of which can give some very strange error messages.

Comments

0

void display(ptr[i]) seems to be a function declaration, but i is no constant and ptr is no type? What is void for?

Comments

0

Change

void display(ptr[i]); 

to

display(ptr[i]); 

When calling a function you don't need to specify the return type.

Also there is a typo in:

for(i-0;i<2;i++) 

I guess you meant i=0

Comments

0

EDIT

When calling display, you should just do it like this:

display(ptr[i]); 

If you insist on clarifying that its type is void, you can use this:

(void)display(ptr[i]); 

You're also missing this at the top of your file:

#include <stdio.h> 

You will need that for the scanf function.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.