I am programing for a while but for this i couldn’t find an answer yet .
lets say i want to run on a loop when i change the names of the variables.
lets say i have :
int ran1;
int ran2;
int ran3;
now i want to run a for loop that put numbers to them :
for(int k=0;k<3;k++)
ran%k=k; // this is wrong ,but i am looking for the correct way .
//output should be :ran1=0 ran2=1 ran3=2..
i know other ways that takes more lines of code .
Make it an array! Using different names differentiated by a number is a bad practice:
Now, instead of using
ran1, orran2, you would useran[1]orran[2].Arrays in C are quite confusing, and they are distinct from pointers.