0
How to copy an array integers to another variable?
for example : int var[]={9}; int someCopy = var[0]; // copy value, assume this is a wrong example int newVar=18; var[0]=newVar; // assign newVar to var[0] how to print someCopy but the value of array var before doesn't change?
3 Réponses
+ 1
To print someCopy, you do :
cout<<someCopy;
0
Can you explain a little more in detail? As far as I can understand, you want var[0] to be 18(newVar) and someCopy to be 9 (var[0]'s original value), right?
Your current assignments do exactly this, and you can print someCopy without worrying about the value of var[0].
0
after array var value change by newVar. how to print current value of someCopy if the command to print, made after changing array var?