Hi, I was learning 'Selection Sorting' in C and while writing my program I constantly get the error-

[Error] expected expression before '{' token
Here's my program-

void main(int A[10])
    int i,j;
        int Min=i;
            int temp=A[i];

If I try to initialize A[10] as a parameter in the function, it gives this error-

[Error] expected ';', ',' or ')' before '=' token

What's the issue?

Recommended Answers

All 4 Replies

What are you trying to do? If you want to assign a value to a[10] you must specify only a single value. If you want to assign multiple values to an array you must do it when the array is declared as

int a[] = {2,4,1,9,0,6,5,7,3,8};

Also main would take only command line parameters like

main(int argc, char **argv)

You don't specify an array size in the parameter list.

You don't specify an array size in the parameter list.

I thought that was pefectly valid in C ... am I wrong?

I'm an old style c programmer. I thought arrays were passed by reference, in which case you pass just the address of the start of the array.

Yes. You can pass the address or the array, but both actually pass the address. Specifying the array size seems to have no real effect other than to document a pre-condition, but maybe there are some subtle differences that are beyond me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.