home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!ames!agate!usenet.ins.cwru.edu!b61539.student.cwru.edu!user
- From: yjc@po.cwru.edu (Jerome 'TofuSoft' Chan)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Porting simple UNIX programs to the MAC??
- Followup-To: comp.sys.mac.programmer
- Date: 12 Dec 1992 00:56:22 GMT
- Organization: The Tofu Society of Singapore
- Lines: 44
- Distribution: na
- Message-ID: <yjc-111292194824@b61539.student.cwru.edu>
- References: <1992Dec11.161544.12668@news.eng.convex.com> <1992Dec11.214417.21082@den.mmc.com>
- NNTP-Posting-Host: b61539.student.cwru.edu
-
- > > I have has a MAC for a while and have ThinkC 4. I have just started trying to port
- > > simple UNIX programs to the MAC. How does one port programs that need command line
- > > arguments? NOTE_ I am running System 6.0.7.
- > >
- > > I have a modest example - fabricated for this question:
- > >
- > > #include <stdio.h>
- > >
- > > void main(int argc, char **argv)
- > > {
- > > ++argv ;
- > > if ( argc < 2 ) {
- > > fprintf(stderr, "usage: how number\n") ;
- > > exit(1) ;
- > > }
- > > printf("The number is %d\n", atoi(*argv)) ;
- > > }
- > >
-
- I'm not sure how it's done under Think C 4.x but under Think C 5.x, you
- would use the ccommand() function.
-
- It's on page 122 of the Standard Library Reference. Here is a sample
- program.
-
- #include <stdio.h>
- #include <console.h> /*Needed for ccommand*/
-
- main(int argc, char **argv)
- {
- int i;
-
- argc = ccommand(&argv) ;
-
- for (i=0; i<argc; i++)
- printf("%s ", argv[i] ;
-
- printf("\n") ;
- }
-
- I hope that helps!
-
- ---
- The Evil Tofu
-