I am just learning C and have my program print out incorrect values but I don't know how to fix it therefore I'd like to have your help. Here is the codes . The test function stores integer numbers (from 0 to 20) in an array and return it. That array is copied to a new array (p[20]) in the main function and I try to print every element of that array out using for loop however the value is not correct, for example i = 0 then p[0] should be 0 but it shows -443987883 ,....
#include <stdio.h>
int test();
int main ()
{
int p[20];
strcpy(p , test);
int i;
int N = 20;
for (i=0; i < N; i++) {
printf ("%i,%i\n", i , p[i]);
}
}
int test (int i , char o[])
{
int N = 20;
for (i = 0; i < N; i++) {
o[i] = i;
}
return o;
}