0

C++.How can I save every value in the loop?

I want to make loop and every time it have to save old values. Example i want to making coordinates .like input: up/down/left/right in loop and moving point in coordinates so it must save values every time. I tried "goto ...; " but it simple restarts everything. So is there any way?

21st May 2021, 11:57 PM
Giorgi Jibladze
Giorgi Jibladze - avatar
3 Respostas
+ 2
Store the values in a data structures, maybe an array.
22nd May 2021, 12:26 AM
Arsenic
Arsenic - avatar
+ 1
If you want the loop to never end, you can make infinite loop like: while(1){} Or for(;;){} And inside the body of the loop save values to some array/vector or any other container you like. But I guess you have to declare that container before entering the loop, other way it will reset with every iteration
22nd May 2021, 4:49 AM
Michal Doruch
0
Understand. Ty ill try it.
22nd May 2021, 8:41 AM
Giorgi Jibladze
Giorgi Jibladze - avatar