![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calling shell functions from another shell script | jisha | Shell Programming and Scripting | 6 | 04-05-2008 04:29 PM |
| How to pass two or more parameters to the main in shell script | pinky | UNIX for Dummies Questions & Answers | 0 | 10-12-2007 11:54 AM |
| calling a prg from the shell!!! | andy2000 | Shell Programming and Scripting | 4 | 03-31-2007 04:02 AM |
| Calling subscript but sleep halts the main script | doublejz | Shell Programming and Scripting | 1 | 09-12-2005 02:08 PM |
| c++ calling main() function | norsk hedensk | High Level Programming | 3 | 01-22-2003 08:28 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Return value (int) from main to calling shell
What is the sytax to return an int from C program main back to calling shell?
Code:
#!/usr/bin/ksh typeset -i NO_RECS $NO_RECS=process_file # Process file is a C program that is set up to return an int from main. The #program complies with no issues, but an error is generated when the shell #calls the program. Is the syntax correct to return the int value to a shell #variable? Code:
int main(argc,argv)
{
int no_recs_tot ;
/* This is just a function within the c program that returns the int value */
no_recs_tot = bld_detail(v_out_path,v_in_path,inrec_cnt,v_src_data_dt);
return (no_recs_tot);
} /* End main */
Last edited by blowtorch; 09-25-2006 at 10:09 PM.. Reason: add code tags |
|
||||
|
Code tags please. Like {code} int main(); {/code} but with [ ] instead of { }.
The syntax for returning a code to the shell is exactly as you show it. What might be wrong is the VALUE you return. Any non-zero value means some sort of error. Zero means success. |
|
||||
|
Plus, on a POSIX compliant system :
Code:
int main()
{
return 42001;
}
Code:
$ cc -o testc test.c $ testc $echo $? 17 Return codes are for program status. |
| Sponsored Links | ||
|
|