c error :expected expression before 'int'

this is my demo .

#include <stdio.h>

int sqsum(int a, ...)
{
    va_list list;
    int b = 0,n = a;
    va_start(list,a);
    while(n > 0)
        {
            b = b+n*n;
            n = va_arg(list,int);
        }
    va_end(list);
    return b;
}

int main(int argc,char **argv)
{
    printf("%d\n",sqsum(1,2,3,-1));
    return 0;
}

then I compile this demo , it occurs this error ,I donot know this error mean.

Answers


If you did not include #include <stdarg.h> and it does not look like you did, then that would explain the error you are seeing, otherwise the program looks correct. If I do not include that header these are the errors I see using gcc:

In function ‘sqsum’:
13:29: error: expected expression before ‘int’

Need Your Help

Handsontable pronunciation

jquery handsontable

Silly question, but I'm anal retentive. :P