Re: c++ question

  • From: "Tyler Littlefield" <tyler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sat, 16 May 2009 08:30:54 -0600

if you have something like:
int add(int a, int b) {
return (a+b);
}

int main(int argc, char** argv)
{
add(30,20);
return 0;
}
it will exit because return 0 is right after that.
You'll need to do something like print out the result,
printf("The result is %d",add(30,20));
that requires you use cstdio.
HTH,

Thanks,
Tyler Littlefield
Web: tysdomain.com
email: tyler@xxxxxxxxxxxxx
My programs don't have bugs, they're called randomly added features.

  ----- Original Message ----- 
  From: tribble 
  To: programmingblind@xxxxxxxxxxxxx 
  Sent: Saturday, May 16, 2009 8:27 AM
  Subject: Re: c++ question


  Haden -- if you called the first function from main, it will return to main 
and continue where it left off. You don't need to do anything special.
  Cherish the good news...
  --le

    ----- Original Message ----- 
    From: Haden Pike 
    To: programmingblind@xxxxxxxxxxxxx 
    Sent: Saturday, May 16, 2009 8:43 AM
    Subject: Re: c++ question


    This is my first program in c++. I did a little of visual basic programming 
a while back but decided to give c++ a try. What my program is doing is calling 
the correct function I want but after that function does its job the program 
exits. My intention was to have it return to the main function so the user 
usually myself, can call another function.
    Haden


    From: tribble 
    Sent: Saturday, May 16, 2009 1:15 AM
    To: programmingblind@xxxxxxxxxxxxx 
    Subject: Re: c++ question


      Hello Haden --
      I don't quite know how to answer, since the behavior you want is exactly 
what C++ is defined to do.
      Could you give an example?
      Is this your first program in C++? or are you talking about something 
more advanced like exception handling that returns control to main from an 
exception point?
      --le



      ----- Original Message ----- 
      From: Haden Pike 
      To: programmingblind@xxxxxxxxxxxxx 
      Sent: Friday, May 15, 2009 10:39 PM
      Subject: c++ question


      Hi all. I am trying to write a consul application in c++. My problem is 
that once it executes a function, I want it to return to the main function in 
this case int main. I am not sure how to accomplish this or maybe I am, it's 
just evading me for now. *smile* Anyway, thanks in advance for any help.
      Haden

Other related posts: