D
Daniel Rudy
Hello,
I'm trying to learn how command line arguments are handled in C. The
following code segment that I wrote as a test program compiles, but when
I try to run it, it core dumps. This is under a FreeBSD environment.
What am I doing wrong here?
/*
just echos the command line arguments onto the screen
tests the format of argument processing
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char argv[])
{
int i; /* generic counter */
printf("argc = %d", argc);
for (i = 0; i <= argc; i++)
{
printf("argv[%d] = %s\n", i, argv);
}
/* return to operating system */
return(0);
}
I'm trying to learn how command line arguments are handled in C. The
following code segment that I wrote as a test program compiles, but when
I try to run it, it core dumps. This is under a FreeBSD environment.
What am I doing wrong here?
/*
just echos the command line arguments onto the screen
tests the format of argument processing
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char argv[])
{
int i; /* generic counter */
printf("argc = %d", argc);
for (i = 0; i <= argc; i++)
{
printf("argv[%d] = %s\n", i, argv);
}
/* return to operating system */
return(0);
}