How to pass an array from SHELL to C function

Hi,

I have an output generated from a shell script like;
0x41,0xF2,0x59,0xDD,0x86,0xD3,0xEF,0x61,0xF2

How can I pass this value to the C function, as below;

int main(int argc, char *argv[]) {
unsigned char hellopdu[]={above value};
}

Regards
Elthox

See the two values main takes? They contain your commandline arguments. argv is an array of strings containing the arguments, and argc tells you how many strings it has in it. In nearly all cases, the first argument is the name the program was run with, and all the ones after it are the ones you want.

Were you to run your program with my_c_program a b c d, then the contents of argv[] would be { "my_c_program", "a", "b", "c", "d", NULL}, and the value of argc would be 5.

So, run the program like

my_c_program 0x41,0xF2,0x59,0xDD,0x86,0xD3,0xEF,0x61,0xF2

and that string will be found in argv[1].