V
vjonweb
Hello!
I am facing an extremely frustrating problem with command line
arguments...I have no clue why it is happening. Any help will be
greatly appreciated.
My program: "a.c"
--------------------------------------------------------
#inlclude<stdio.h>
int main(int argc, char * argv[])
{
fprintf(stderr,"%d\n",argc);
fprintf(stderr,"%s",argv[0]);
return 0;
}
--------------------------------------------------------
If I compile this program using
cc a.c
and then run it using
../a.out arg1 arg2
the program displays
--------
3
a.out
--------
which is fine!!
However, if I compile & link this program separately using
cc -c a.c
ld -lc -ldl a.c
and run it using
../a.out arg1 arg2
the program displays
--------
0
Segmentation Fault, Core dumped
--------
I cannot understand this at all. Please help....
vj
I am facing an extremely frustrating problem with command line
arguments...I have no clue why it is happening. Any help will be
greatly appreciated.
My program: "a.c"
--------------------------------------------------------
#inlclude<stdio.h>
int main(int argc, char * argv[])
{
fprintf(stderr,"%d\n",argc);
fprintf(stderr,"%s",argv[0]);
return 0;
}
--------------------------------------------------------
If I compile this program using
cc a.c
and then run it using
../a.out arg1 arg2
the program displays
--------
3
a.out
--------
which is fine!!
However, if I compile & link this program separately using
cc -c a.c
ld -lc -ldl a.c
and run it using
../a.out arg1 arg2
the program displays
--------
0
Segmentation Fault, Core dumped
--------
I cannot understand this at all. Please help....
vj