Why is the original array still affected?
I used the memcpy() function and tried running an operation on the duplicated array which was to make every element in the array negative. I'm not exactly sure why the original array is also affected. The arrays were dynamically allocated. Here is the code snippets: void Fill_dyn_arrays(int array_1[],int array_2[],int array_3[],int array_4[], int inputVal1, int inputVal2,int inputVal3,int inputVal4) { //Not the full algo just the important stuff you need to know. This works //fine for(int i = 0; i <= inputVal1 ; i++){ array_1[i] = rand() % inputVal1; } } void Negative_inv(); int main() { int *
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.