Hallo
I start to learn C++
And now I am in the lesson of passing array in a function as argument.
I played with that and I made that code:
Code:
#include <iostream>
using namespace std;
void exa(int arr[]) {
for(int x = 0; x<5; x++){
cout << arr[x] << endl;
// show the data that passed from the array
// in the main function
}
cout << "#########"<< endl;
for(int a = 0; a<5; a++){
cin >> arr[a];
cout << arr[a] << endl;
//Changing the data in that array (arr[])
//to the input : 1, 2, 3, 4, 5
// and then show the data
}
}
int main() {
int arry[] = {22, 43, 3, 12, 4};
exa(arry);
// passing the arry[] data to the function
cout << "***********" << endl;
for (int b =0; b<5;b++){
cout << arry[b] << endl;
// checking the array data to see if it
// remains the same
}
}
So I dont understand why the data in the array in the main function (arry[]) change..
Its should show me its original data
(22, 43, 3, 12, 4) but instead it show me the data from the input(1,2,3,4,5)
Why? What I am missing here..
Thank you