• + 0 comments

    Why am I getting this error when I have not even touched main() ?

    Here's my function code

    int i,j,arr[queries_count];
    *result_count=queries_count;
    k = k % a_count;
    for(i=1;i<=queries_count;i++)
    {
        j=queries[i]-k;
        if(j<0)
            arr[i]=a[a_count+j];
        else
            arr[i]=a[j];
    }
    return arr;
    

    }

    Segmentation Fault Error (stderr)

    GDB trace: Reading symbols from solution...done. [New LWP 2592] Core was generated by `solution'. Program terminated with signal SIGSEGV, Segmentation fault.

    0 fprintf (__fmt=0x400cc4 "%d", __stream=0x155d010)

    at /usr/include/x86_64-linux-gnu/bits/stdio2.h:97
    

    97 return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,

    0 fprintf (__fmt=0x400cc4 "%d", __stream=0x155d010)

    at /usr/include/x86_64-linux-gnu/bits/stdio2.h:97
    

    1 main () at solution.c:97