I wrote such code, but it shows only this:
2
2
2
2
2
2
...
and thats not the output I would like to get.
Heres the code:
void fun(int *tab, int n)
{
int i, wsk = &tab;
for(i=0; i<n; i++)
{
printf("%d\n", *(tab+1));
}
}
int main(int argc, char **argv)
{
int tab[] = {1,2,3,4,5,6};
fun(tab, 6);
return 0;
}
The second version I tried, doesnt work at all:
void fun(int *tab, int n)
{
int i, wsk = &tab;
for(i=0; i<n; i++)
{
printf("%d\n", *(wsk+i));
}
}
int main(int argc, char **argv)
{
int tab[] = {1,2,3,4,5,6};
fun(tab, 6);
return 0;
}
Code::Blocks says that:
|49|error: invalid type argument of unary ‘*’ (have ‘int’)|