error in my function not sure

For this function I am supposed to call my like this but for some reason this error keep coming up "redefinition of formal parameter 'size'. (If your wondering what printArray does, it takes the elements of the arr and prints them out according to the size of the given from chartToInt function).

int arr[SIZE];
int size = 0;
charToInt("Enjoy!",arr,size);
printArray(arr,size);
cout << "Size is: " << size << endl;


1
2
3
4
5
6
7
8
9
10
void charToInt(string str, int arr[], int& size)
{
	int size = str.length();

	for(int i = 0; i <= (size - 1); i++)
	{
		int arr1 = arr[i]; 

	}
}
You are taking 'size' as a parameter, but then you redeclare it on line 3. Just assign to it normally instead.
Thanks I figured it out :)
Topic archived. No new replies allowed.