Hi
How to pass multi line text as a command line argument to a program.
(i.e)
./a.out hi this is sample 0 file1
where
hi this is sample should be stored in argv[1]
0 in argv[2] and so on...
Hi
How to pass multi line text as a command line argument to a program.
(i.e)
./a.out hi this is sample 0 file1
where
hi this is sample should be stored in argv[1]
0 in argv[2] and so on...
Based on your current input,
./a.out "hi this is sample" "0" ...## and so on.
Enclose space seperated arguments to prevent the shell from interpreting them.
and what if " itself is the argument
./a.out "simple" "\""
kcsdev:/home/jmcnama> cat a.c
int main(int argc, char *argv[])
{
int i;
for (i=0;i<=argc;i++) printf("%s\n", argv);
return 0;
}
kcsdev:/home/jmcnama>cc a.c
kcsdev:/home/jmcnama> a.out "simple test" "b" '"'
a.out
simple test
b
"
kcsdev:/home/jmcnama> a.out "simple test" "b" \"
a.out
simple test
b
"
M -
This is a shell question ,not a C question, IMO.