Advertisement

Ending in function...

Started by March 19, 2000 11:14 AM
11 comments, last by Znipper 24 years, 7 months ago
Look at the shown example...this is not the actual program I''m writin''... =) #include int end (); int main () { int mamasAge; cout << "Your mama is how old?" << endl; cin >> mamasAge; if (mamasAge < 40) // If this happens I want the program to END... end (); if (mamasAge > 40) cout << "Your mama was quite old!"; // I do not want this to show if mamasAge is less then 40... cout << "You got her phonenumber?"; } int end () // I want this function to END the program... { cout << "Wow! Young one huh?" << endl; }
try putting a return 0 at the end of the end()
and try this
If (mamasage > 40)
{
cout << "Your mama was quite old!" << endl
<< "You got her phone number?" << endl;
}
Advertisement
If it isn''t in main you can just exit the program from anywhere with (suprisingly enough )

exit(0);
What you talkin'' about Vallis???

Writing another function won''t
end the program...
quote: Original post by Znipper

What you talkin'' about Vallis???

Writing another function won''t
end the program...


You really don''t know what you''re talking about, do you?
exit() is part of the C runtime!

From MSDN:
quote:
exit, _exit
Terminate the calling process after cleanup (exit) or immediately (_exit).

void exit( int status );

void _exit( int status );
Ups, my bad...

But you dont have to get all cocky, SiCrane...
Advertisement
also, you should probably declare end as void, instead of int.

quote: Original post by Znipper

Ups, my bad...

But you dont have to get all cocky, SiCrane...


<rand>
And you don''t have to insult people trying to help you either. If people think you''re going to be belligerent when they offer you an answer that doesn''t fit in your pre-conceived notions of how thing work, why would they want to help you? And more importantly, how are you going to learn? You could have at least tried it, *before* saying that he didn''t know what he was talking about. This place is all about community. *I''m* not getting paid to offer advice here. I''m pretty sure neither is he. The vast majority of us are posting entirely out of good will. Bottom line: if you want courtesy, offer courtesy first.
</rant>
I didn''t in anyway insult Vallis, I was
just asking him what the heck he ment with
his message. I am a total newbie so why
assume that I know what he meant?

I did try it out before replying but
I couldn''t get it to work...

And by the way, I''m sure Vallis can speak for himself
if I insulted him (wich I didn''t).

And "What are you talkin'' about???" does NOT
mean "You don''t know what you are talking about".
I''m am sure Vallis is a lot better than me
when it comes to c++...no doubt.

So back off, SiCrane.
I''m on your side here, SiCrane (if I might interfere), you (Znipper) shouldn''t say things you don''t know for sure, even if you''re a newbie. If you have to (if it''s just an idea or thought) please say so in the post, or it''ll be confusing.

If you say something bad and someone thinks you''re right, that''s really no good.

============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown
============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown

This topic is closed to new replies.

Advertisement