This has the functionality I want (and it works)
#include <stdio.h>
//includes other libraries needed
int foo();
int main()
{
while(true)
{
while(foo()==1)
{
//do something
}
//does other unrelated things
}
}
int foo()
{
// Returns if a switch is on or off when the function was called
// on return 1;
// off return 0;
}
However, I would like this to happen:
#include <stdio.h>
//includes other libraries needed
int foo();
int main()
{
while(true)
{
//THIS IS THE PROBLEM
int something = foo();
while(something==1)
{
//do something
}
//does other unrelated things
}
}
int foo()
{
// Returns if a switch is on or off when the function was called
// on return 1;
// off return 0;
}
How can I have the something variable update each time the inner while loop is called? I know it has something to do with &
or *
for references and pointers but I haven't been able to find an example online about this.
Also I cannot edit anything within the foo()
function.
Thanks.