I was going through (Week 2> Section>Variables and Scope) when I wrote this piece of code : `
int set_int(int x);
void set_array(int array[4]);
int main(void)
{
int a = 10;
a = set_int(a);
int b[4] = {0, 1, 2, 3};
set_array(b);
printf("%d, %d\n", a, b[0]);
}
int set_int(int x)
{
x = 22;
}
void set_array(int array[4])
{
array[0] = 22;
}
BTW this is a little bit bad designed, I must admit :P.
Anyway, why when I try to compile it it give me an error with the int set_int
code and it prints this whenever I try to compile it :
error: control reaches end of non-void function [-Werror,-Wreturn-type]
}
^
Nonetheless, if I delete the set_int
code, the set_array
works fine.
Thank you in advance :)