Feb 13, 2020 at 7:12pm UTC
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?
Feb 13, 2020 at 7:29pm UTC
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.
Feb 13, 2020 at 7:39pm UTC
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 Feb 13, 2020 at 7:39pm UTC
Feb 13, 2020 at 7:43pm UTC
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.