How to quit void functions

M

Martin Johansen

Hello.

I have a void function.

Now, how do I exit the function at a random line in the code?

Normally I would use the return statement.

Thanks.
 
M

Martin Ambuhl

Martin said:
Hello.

I have a void function.

Now, how do I exit the function at a random line in the code?

Normally I would use the return statement.

To return from the function at any specified point use the return
statement. Exiting randomly is not a good idea.
 
G

Gordon Burditt

I have a void function.
Now, how do I exit the function at a random line in the code?

Normally I would use the return statement.

Use the return statement.

void logerror(char *msg)
{
if (msg == NULL) {
return;
}
if (msg[0] == '\0') {
return;
}
... stuff to output the string pointed at by msg to a log file ...

return; /* optional */
}

Gordon L. Burditt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top