-
Return Values ( C )
If I have the function:
int something(char *s_ptr)
{
run some comparison tests
IF true
return (TRUE)
}
The returned value then needs to be compared in the program, to allow another loop to start, where is the value returned to and would it be okay to test for it with:
if (TRUE)
{
code bits
}
or would this cause another horrible error, like the ones I'm so used to?
-
You can put the function call to something directly in the if test like so:
Code:
if( something( "hello" ) )
{
code bits
}
Or you can assign the return value to a temporary/local variable in the function calling the something function and then test that variable like so:
Code:
int result = something( "hello" );
if( result )
{
code bits
}
-
Hey, the man's a genius...
Thanks!