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

How to restart PostgreSQL sequences handled by Hibernate?

hibernate postgresql

I've been tasked with restarting a sequence for many different serial columns in a PostgreSQL database. Normally, I would simply use:

nyroModal dialog in Chrome: How to get rid of scrollbars or set size explicitly?

jquery-plugins google-chrome dialog scrollbar nyromodal

I seem to have stuck numerous hours in a modal dialog with unexpected behavior in Chrome, for which I could use your help. The dialog is a hidden div consisting of two smaller divs, one floated lef...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.