I got this error and have no idea what it means... May i get a little help please ?
error C2059: syntax error : ']'

[
#include <iostream>
using namespace std;

int broj (int be, int a[])
{
	int br=0;
	int f=0;
	int b[200];
	for(int i=0;i<=br;i++)
	{
		for (int j=0;j<=br;j++)
		{
			if ((a[i]==a[j]) && (i!=j))
			{
				a[j]=0;
			}
		}
		for (i=0;i<=be;i++)
		{
			if(a[i]!=0)
			{
				b[f]=a[i];
				f++;
			}
		}
	}
	return (f);

}
void main ()
{
	int i=0,be=10,f=0;
	int a[]={1,1,5,7,8,9,9,11,55,66,};
	cout<<"Vnesete kolku elementi ke se citaat od tastatura"<<endl;
	for(i=0;i<=be;i++)
	{
		cin>>a[i];
	}
	f=broj(be,a[]);
	cout<<"Novoto pole ima "<<f<<"elementi"<<endl;
	cin>>i;


}
]
It's in the line "f=broj(be,a[])", but why the ']' is a problem ???

Recommended Answers

All 2 Replies

To pass an array, you just need the name (no [ ] needed in the call)

Also, for loops should generally be < n ( and not <= n )
Yours runs off the end of the array.

Also, why not just say int a[10]; rather than initialising it with 10 elements which you're just going to overwrite anyway.

Don't forget, void main is wrong. Main returns int.

Ok, int main it will be :) Thanks man, I appreciate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.