Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to exit from a function?

Status
Not open for further replies.

clifff

Programmer
Mar 22, 2002
20
MD
How can i exit from function and to continue running the programm?
ex:

function(){

line1;
line2;
if(..){
line n;
line n+1;
//I want to break here !!!
}else{..}

line k; //I want to continue from this line!

I tried exit but this stops the whole program. I tried break but i see in Borland it doesnt work as it suppose to work in C++.



 
Have you tried return?

James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
he's right. return exits the function, slugger. Cyprus
[noevil]
 
OR you can use the "goto":

function(){

line1;
line2;
if(..){
line n;
line n+1;
goto Label_One; //I want to break here !!!
}else{..}
Label_One:;
line k; //I want to continue from this line!

Thi is however a dirty way of doing i but it works.
 
EEEK [thumbsdown] Using goto is bad practice! I highly suggest using return and NOT goto

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top