that one compiles and runs.... I can't get the second to compile.

#include <stdio.h>
int main (int argc, char * argv[])
{
int argcount=1; /* argv 1 is the first parameter */
int mode;
while(argcount < argc )
    {
    if(strcmp(argv[argcount],"-mode1") == 0)
        {
        argcount++;
        printf("mode 1 parameter = %s\n",argv[argcount ++]);
        mode =1;
        }
    else if (strcmp(argv[argcount],"-mode2") == 0)
        {
        argcount++;
        printf("mode 2 parameter = %s\n",argv[argcount ++]);
        mode =2;
        }
    else if(strcmp(argv[argcount],"-help") == 0)
        {
        argcount++;
        printf("Help mode\n");
        }
    else
        {
        printf("unknown command %s\n",argv[argcount]);
        exit(1);
        }
    }
printf("end of program in mode %d\n",mode);
}

On Mon, Dec 19, 2011 at 3:24 PM, Kevin Fries <kevin@fries-biro.com> wrote:
On Mon, 2011-12-19 at 15:07 -0700, Michael Havens wrote:
> I might be grren but I did put the '#include<stdlib.h>' in. In fact I
> copied the entire file and it didn't compile.

Not sure what was wrong.

I was able to run your example:

kfries@kfries-laptop:tmp$ cat argexample.c
#include <stdio.h>

int main (int argc, char **argv) {
  int count;
  for (count = 0; count < argc; count++) {
     printf ("argument no %d = %s\n", count, *argv++);
  };

  return 0;
}
kfries@kfries-laptop:tmp$ gcc -o argexample argexample.c
kfries@kfries-laptop:tmp$ ./argexample hello world
argument no 0 = ./argexample
argument no 1 = hello
argument no 2 = world


Hope this helps
Kevin

---------------------------------------------------
PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss



--
:-)~MIKE~(-: