<<Q>>No command-line arguments in C?

<<Q>>No command-line arguments in C?

Post by Akm36 » Sun, 26 Apr 1998 04:00:00



I know there isn't a command-line on a Mac, but how does one pass parameters to
your C app from the main?

I tried doing the following

#include...

int main(int argc, char* argv[]){
        printf("%s", argv[0]);
        return 0;

Quote:}

waiting for something to prompt me to enter something...but NOTHING OCCURRED!

So, how does the argc, argv parameters work in C on a Mac?

Thanx in advance...
al

 
 
 

<<Q>>No command-line arguments in C?

Post by Don Arb » Sun, 26 Apr 1998 04:00:00



:  I know there isn't a command-line on a Mac, but how does one pass
parameters to
:  your C app from the main?
:  
:  I tried doing the following
:  
:  #include...
:  
:  int main(int argc, char* argv[]){
:          printf("%s", argv[0]);
:          return 0;
:  }
:  
:  waiting for something to prompt me to enter something...but NOTHING OCCURRED!
:  
:  So, how does the argc, argv parameters work in C on a Mac?
:  
:  Thanx in advance...
:  al

Use ccommand(), code it like this, you will get a command line dialog box
when your program starts up:

#include <console.h>

int main(int argc, char *argv[]) {

   argc = ccommand(&argv);

   printf("%s", argv[0]);

   return 0;

Quote:}

Remember though that argv[0] is always set to the name of your program,
command line prarameters start at argv[1].

Don

--
Don Arbow, Partner, CTO
EveryDay Objects, Inc.

http://www.edo-inc.com

 
 
 

<<Q>>No command-line arguments in C?

Post by John More » Mon, 27 Apr 1998 04:00:00



> I know there isn't a command-line on a Mac, but how does one pass
> parameters to your C app from the main?

> I tried doing the following

> #include...

> int main(int argc, char* argv[]){
>   printf("%s", argv[0]);
>   return 0;
> }

> waiting for something to prompt me to enter something...but NOTHING
> OCCURRED!

> So, how does the argc, argv parameters work in C on a Mac?

The best way of doing this is by use of appleevents.  Not only can it do
everything that you want, it can also be used to send the command or a
different one at a latter time.

You should be able to find plenty of examples and it'll work better than
any other solution.

--
John Moreno

 
 
 

1. <<<<< HELP: Creating new project >>>>>

Dear CodeWarriors,

I encountered some strange problem creating C/C++ 68k/ppc toolbox
project, I contacted Ron personally just a while ago and he could not
re-produce my problem. Just curious if the others had a similar
experience before otherwise I might submit a (hopefully not) bug report
later.

Below is my conversation with Ron ......

---------------------

Hi Wallace,

Works perfectly for me.  Try dragging and dropping the entire (Project
Stationery) folder to your Metrowerks CodeWarrior folder and replacing
what you have there now.

If that doesn't work, all I can think of is maybe you need to rebuild
your desktop or something.  If that fails, call tech support or write up

in the Release Notes : email forms folder.

I just can't duplicate this, but maybe they will have a system similar
to yours that they can try it on there.

Ron

2. Very Very Hot requirement for Business Objects--CT and WA

3. >>>>>TWO NIGHTS AND STILL NO LIGHT IN SIGHT>>>HELP<<<<<<<<<

4. Only certain users' mail goes to smarthost?

5. <<<<>>>> WANTED : Library of low level or undocumented hacks <<>>

6. ObjectThread 0.4.4 Released

7. >>> NEED PROGRAMMER <<<

8. Sufrace visualization in MATLAB

9. >>> MFC <<< Linking Help!!!

10. >>> 9 0 % O F F <<<

11. MSL 2.1.1 Update <clap><clap><clap>

12. <<<<< CodeWarrior Hong Kong User ?! >>>>>

13. <<<< SPY ON ANYONE ON-LINE NOW! >>>>