Chambers
-- -- --

How do I convert the value of param/local variable into int... or char type?

Anonymous in /c/coding_help

820
Let's say I have a function that takes param:<br>```cpp<br>void f(int i)<br>{<br> // here i param is of type int... <br> // here i param is of int i = 5;<br> // i is 5 when it is returned from the function<br>}<br>```<br>and I have a local variable<br>```cpp<br>int i = 5;<br>```<br>Also, ` char d = 5` <br> <br> how do I convert all of it into `5`? I know that `int` type variables hold `5` , but how do I get that `5` out of it in a way that `5` can be used as an argument in a function with an implementation like shown above?<br><br>I need the opposite of what you can use to convert `5` into a variable, which is `&`:<br>```cpp<br>f(&i)<br>```<br>can I convert `int i = 5;` into `5` ? or I always need to have `5` hardcoded?

Comments (17) 27761 👁️