[comp.sys.cbm] C Power problems with argc and argv

cuda@ihlpg.UUCP (Nelson) (01/22/87)

I wrote this short program to experiment with argv and argc.
The output is always the same.  Argc is zero and argv is 
empty (probably because of argc).  Has anyone gotten these
things to work?  Does anyone know what the command syntax
should be?  I have tried both in and out of the shell.


include "stdio.h"

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

Thanks
Mike Nelson
ihlpg!cuda

miket@masscomp.UUCP (01/23/87)

In article <2755@ihlpg.UUCP> cuda@ihlpg.UUCP writes:
>I wrote this short program to experiment with argv and argc.
>The output is always the same.  Argc is zero and argv is 
>empty (probably because of argc).  Has anyone gotten these
>things to work?  Does anyone know what the command syntax
>should be?  I have tried both in and out of the shell.
>
>include "stdio.h"
>
>main(argc, argv)
> 
>int argc;
>char *argv[];
>{
>int i;
> printf("argc = %d\n",argc);
> printf("argv = ");
> for (i=0;i<argc;i++){
>  printf("%s, ",argv[i]);
> }
>}

I'm not familiar with C-power, but all the C compilers that I have used
need an " # " in front of the include. There is nothing wrong with the
code, mayby the problem isn't with argv & argc, but with the compiler
not giving an error when it doesen't have an " # " in front of things
like #include, #define, #ifdef etc... Does any one else out there care to
comment about this. 

#include "stdio.h"

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

This worked fine for me, and should work on any machine with C.

mike truax
UUCP:			{inhp4,seismo,decvax,}!masscomp!miket

cagordon@watnot.UUCP (01/24/87)

In article <1357@masscomp.UUCP> miket@masscomp.UUCP (Mike Truax) writes:
>In article <2755@ihlpg.UUCP> cuda@ihlpg.UUCP writes:
>>I wrote this short program to experiment with argv and argc.
>>The output is always the same.  Argc is zero and argv is 
>>empty (probably because of argc).  Has anyone gotten these
>>things to work?  Does anyone know what the command syntax
>>should be?  I have tried both in and out of the shell.
>I'm not familiar with C-power, but all the C compilers that I have used
>need an " # " in front of the include. There is nothing wrong with the
>code, mayby the problem isn't with argv & argc, but with the compiler
>not giving an error when it doesen't have an " # " in front of things
>like #include, #define, #ifdef etc... Does any one else out there care to
>comment about this. 

Yes, in fact C-Power DOES require the '#' but I don't know what happens if it's
not there (I always have it in)

--
Chris Gordon                     UUCP: {abunchasystems}!watmath!watnot!cagordon
U of Waterloo, Ont         CompuServe: 72030,104
				CSNET: cagordon%watnot@Waterloo.CSNET
-------------------------------------------------------------------------------
"I always have fun 'cause I'm out of my mind!!!" - ZTP

cuda@ihlpg.UUCP (01/26/87)

> In article <2755@ihlpg.UUCP> cuda@ihlpg.UUCP writes:
> 
> I'm not familiar with C-power, but all the C compilers that I have used
> need an " # " in front of the include. There is nothing wrong with the
> code, mayby the problem isn't with argv & argc, but with the compiler
> not giving an error when it doesen't have an " # " in front of things
> like #include, #define, #ifdef etc... Does any one else out there care to
> comment about this. 
> 

 Yes.  Kermit ate the pound sign when I sent it from home to work to 
postnews it.

 Mike Nelson