Refrencing the location of an array

I'm writing a function in which a char array is scrambled. I know that normally, you have to refrence the location of the variable (&), but when I did this in the declaration of the function, it returned an error. Any help?
Arrays are passed as pointers anyway.
1
2
3
4
5
6
int scramble(char s[]);
int main(){
	char inp[]="HI WORLD";
	scramble(inp);
}
//define scramble here... 
It doesn't work though... this is the function i wrote. When it is run, it just returns the same array as was imputted.
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
void scrambleChar (char cArray[])
{
    
    int nHowMany = 0;
    
    for (; cArray[nHowMany];nHowMany++) {
        int temp = 0;
    }
    
    char cArrayFinal[nHowMany];
    
    for (int i = 0;i<nHowMany; i++) {
        cArrayFinal[i] = cArray[i];
    }
    
    int nArray[nHowMany];
    
    for (int i = 0; i<nHowMany; i++) {
        nArray[i] = i;
    }
    
    random_shuffle(nArray, nArray + nHowMany);
    
    for (int i = 0; i<nHowMany; i++) {
        cArray[nArray[i]] = cArrayFinal[i];
    }
    for (int i = 0; i<nHowMany; i++)
    {
        cArray[i] = cArrayFinal[i];
    }
}
This is what you must do you must send the array itself. your code only send an array to the function and after finishing function life of array will be finish...

1
2
3
4
void UpperCase(char *S){
	for(int i=0;S[i];i++)
		S[i] = toupper(S[i]);
}



char *S

* This means the value of where S points at and above codes gets an array from program and uppercase the array and all over the program array is uppercase.

Topic archived. No new replies allowed.