calling C main from Objectivec

I want to call a C classes main function from within another class (which is written with objectiveC). I would like to pass some arguments to the main. I tried it like this, but the frist parameter gets ignored:

char *argv[] = 
{ 
    "--a", 
    "--b", 
    srcFile , 
    destFile
};
my_c_main(4, argv);

Am I doing something wrong?

Answers


the first entry in the argv array is the application name itself. so if you want to pass arguments, skip the first entry and start your args at the second entry in the array. you could probably just use an empty string as the first array element.

char *argv[] = 
{
    "", 
    "--a", 
    "--b", 
    srcFile , 
    destFile
};
my_c_main(5, argv);

Need Your Help

Concatenating 'audio/x-wav' buffer and serving with 'Transfer-Encoding': 'chunked'

node.js buffer wav audio-streaming chunked-encoding

This question is a followup to a previous question, that was resolved thanks to @thejh.

Two Column Div Layout: Left = Fluid, Right = Fixed and Scrollable

css html layout

The layout for this is rather simple and easy to achieve and has been covered here a lot, my problem comes from when I want the right div to be scrollable.