CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Return from function early

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bwgames



Joined: 21 Jul 2005
Posts: 36

View user's profile Send private message

Return from function early
PostPosted: Thu Aug 17, 2006 7:33 am     Reply with quote

Hiya,

I have a void function that I want to leave before the end of the function is reached, dependant on IF functions.

I've tried return(); but compiler errors with "Return value not allowed in void function" - is there another command that will abort the function?
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Thu Aug 17, 2006 8:38 am     Reply with quote

Try:

return;

no ().

Ronald
Guest








PostPosted: Thu Aug 17, 2006 12:46 pm     Reply with quote

Uhhh.....

Things like Label/Goto, End/Stop, Return in a void function just to make the code stop are all regarded as poor programming methods in C.

If you can't think of a logical way to end your code from inside a function (I doubt its nothing a clevel if/else couldn't do), then make it an int or int1 function and find a way to use the returned data to your advantage.

Its easy to program like that, but in the end it will bite your [spam].
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group