The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-18-2008
Registered User
 

Join Date: Dec 2007
Posts: 8
Unhappy quicky but needy question....

int abc()
{
int a=2, b=1, sum, diff;
sum = a+b;
diff = a-b;


}


int main()
{
int sum, diff;

abc();

...
...
...

return 0;
}
-------------------------------
how can i pass the 2 values: sum & diff in abc() into main() when i call it ? thx.

Last edited by trapeze; 03-18-2008 at 10:00 PM.
Reply With Quote
Forum Sponsor
  #2  
Old 03-19-2008
Registered User
 

Join Date: Dec 2007
Posts: 8
Red face

Quote:
Originally Posted by trapeze View Post
int abc()
{
int a=2, b=1, sum, diff;
sum = a+b;
diff = a-b;


}


int main()
{
int sum, diff;

abc();

...
...
...

return 0;
}
-------------------------------
how can i pass the 2 values: sum & diff in abc() into main() when i call it ? thx.
Code:
int abc(int *sum, int *diff)
{
  int a=2, b=1;
  *sum = a+b;
  *diff = a-b;

  return 0;
}


int main()
{
  int sum, diff;

  abc(&sum,&diff);

  return 0;
}
voila

Last edited by Yogesh Sawant; 03-19-2008 at 02:36 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0