3 little complile errors

I'm must write a program that moves each element of an array to the left with 1 position. I get 3 errors when I compile it and I don't know why.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>



using namespace std;

void shift(int &array[100],unsigned int n)
{
    unsigned int i,aux;
    
    for(i=1;i<=n;i++)
    {
        aux=array[i];
        array[i]=array[i+1];
        array[i+1]=aux;
    }

}



 main()
{

int array[100];unsigned int n,i;
cin>>n;

for(i=1;i<=n;i++)
cin>>array[i];

shift(array,n);

for(i=1;i<=n;i++)
cout<<array[i]<<' ';
}


All three on line 7:
D:\CodeBlocks\programe\1_20_euler.cpp|7|error: declaration of 'array' as array of references|
D:\CodeBlocks\programe\1_20_euler.cpp|7|error: expected ')' before ',' token|
D:\CodeBlocks\programe\1_20_euler.cpp|7|error: expected unqualified-id before 'unsigned'|
||=== Build finished: 3 errors, 0 warnings ===|
Last edited on
Just remove the & from array[100] there.
but I need it to transmit the x[i] value through reference
It will still be passed by reference, since you're passing a pointer.
Last edited on
Topic archived. No new replies allowed.