Error when building project

I'm having a problem compiling this program it gives me the following errors:
Severity Code Description Project File Line Suppression State
line20 type name is not allowed
line 20 identifier slices is undefined


//main
#include <iostream>
#include "header.h"

using namespace std;

int main()
{
{

int x;
int y;
int placehold;
cout << "Enter slices eaten by each person (up to 10 ppl)\n";
int slices[10];
for (x = 0; x < 10; x++)
{
cin >> slices[x];
}
}
int mode = findMode(slices[10], int);
cout << "Mode of slices eaten is" << mode;
}

//header
int findMode(int [10], int);

//function prototype
#include <iostream>
#include "header.h"

using namespace std;

int findMode(int slices[10], int)
{
int count;
int mode;
mode = 0;
int *slices;
bool flag = true;

for (int x = 0; x < 10; x++)
{
count = 1;
while (slices[x] == slices[x+1])
{
count++;
x++;
}
if (count > mode)
mode = slices[x];
if (count > 1)
x--;
}
return mode;
}

Use [code][/code] tags when posting code, it's the <> icon on the right.

> int mode = findMode(slices[10], int);
You need to replace the function prototype parameters with actual variable names.

Eg.
int mode = findMode(slices, 10);


1
2
3
4
5
6
int findMode(int slices[10], int)
{
int count;
int mode;
mode = 0;
int *slices;  //!! remove this line 
When I did what you said it adds another error that says type name not allowed.
Show us your new code - properly formatted with code tags - and tell us exactly what the error message is, and on what line it is occurring.

Please remember, this is the C++ forum, not the telepaths forum. We cannot read your mind.
Topic archived. No new replies allowed.