if i name a vairbale in one function(main) how can another function read it
if i name a vairbale in one function(main) how can another function read it
If a variable is declared in a function, then it is local to that function and cannot be used by another function.
damn really? that sux
can vairbles between to header files read eahcother
It doesn't suck, it very logical. But there are many ways to solve such situation.
You could introduce a global variable and use it. It is not a very nice way, because programmers should reduce global variable use as much as possible. But in parallel functions it could be necessary. If you're not doing parallel things, you could consider to pass the variable back to the calling function.
if u want a function to have access to it then pass the variable by reference to the function.
Code:include <iostream.h> void function(int *var) { *var = 0; } int main() { int number = 6; cout << number; function(&number); cout << number; return 0; }
function(&number, &number2, &number3);
woudl i do that if i had multiple varibles
you've got it.
just be sure to change the function definition also.
k