Originally Posted by
kuletako327
in reality you wont know how many "case"s there will be it just depends on how many inputs the user makes.
Good. For starters, compare this:
to what you eventually wrote:
Code:
int sieve(int * d[])
Adding the * is fine, but you left the "array syntax" version of the pointer, so what you ended up with is actually equivalent to:
Rather, it would have sufficed to change it to:
I suspect that this will be enough to fix your problems. But if you want this assignment to be actually useful, consider this loop (my own example code snippet, not related to your code other than that d is a pointer to the first character of an array with MAX elements):
Code:
int i;
for (i = 0; i < MAX; ++i)
{
if (d[i] % 2 == 0)
{
d[i] = 0;
}
}
We could trivially change it to use pointer notation:
Code:
int i;
for (i = 0; i < MAX; ++i)
{
if (*(d + i) % 2 == 0)
{
*(d + i) = 0;
}
}
But it would be more interesting and useful if we actually used a pointer to iterate over the array:
Code:
int *i; /* i is now a pointer! */
for (i = d; i < d + MAX; ++i)
{
if (*i % 2 == 0)
{
*i = 0;
}
}