D
D
Detcelfer2018-12-12 00:13:24
Arduino
Detcelfer, 2018-12-12 00:13:24

How to find a variable that is specified in a function as a parameter?

int var1 = 1;
int var2 = 2;
void someFunction( int used_variable) {
  used_variable +=1;
  //??? код который вернёт подставленной переменной значение 
}
// чтобы на выходе было так:
someFunction(var1);
// var1 стала равна 2
someFunction(var2);
// var2 стала равна 3

As I understand it, not a variable is substituted into the function, but only its value, but what if I need to implement something similar? what are the workarounds?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2018-12-12
@detcelfer

Passing parameters by reference

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question