expression must have pointer-to-object type

so my programs goes like this.
i = 0;
while (i < 5)
{
if (y[i] < min) //expression must have pointer-to-object type
{
min = pocty[i];
}
i++;

}

I have no idea what does that mean. Any suggestions?
You did not show us how y and pocty are defined. You are indexing into them as if they were arrays, and they may not be.

the full code is here
#include <stdio.h>

void main()
{
int i = 0; int cisla[6]; int pocty[50]; int y;

while (true)
{
if (i > 15)
{
pocty[i] = 0;
i++;
}
else
{
break;
}
}
i = 0;
while (i < 5)
{
scanf_s("%i", &cisla[i]);
i = i + 1;
}
i = 0;
int min = pocty[0];
while(cisla[i] == cisla[1] || cisla[i] == cisla[2] || cisla[i] == cisla[3] || cisla[i] == cisla[4])
{
if (i > 5)
{
break;
}
else if (y > 5)
{
i++;
y = 0;
}
else if (cisla[i] == cisla[y])
{
pocty[i] = pocty[i] + 1;
y++;
}
}
i = 0;
while (i < 5)
{
if (y[i] < min)
{
min = pocty[i];
}
i++;

}

}
Last edited on
Your value y is a simple integer. You cannot index it like an array.

An array is seen as a pointer to the first element, so the error about "must have pointer-to-object type" means that the variable you are indexing is not an array.
That aside, what is the logical operation that you do in this:
1
2
3
4
5
6
7
8
9
10
int min = pocty[0];
int i = 0;
while (i < 5)
{
  if (y[i] < min)
  {
    min = pocty[i];
  }
  i++;
}

Are you looking for the smallest pocty?
If yes, what has the y got to do with it?
Registered users can post here. Sign in or register to post.