I am trying to initialize *argv with these values : test_file model result Can anyone help me how to directly initialize the argv instead of using command line. I am doing it like this:
*argv[]= {"test_file","model","output",NULL};
but its not working. I know its simple but i am new to programming. Can anyone help me?
Initialisation like that is only available at declaration time, and (presumably) you've declared argv as a parameter to your function (
main
I assume). You will have to assign each individually in this instance.To conform with newer compilers, I would do this (as long as you don't want to change the strings):
One thing to be aware of is that the standard
argv
strings are permitted to be modified. These replacement ones cannot be (they're literals). If you need that capability (which many option parsers might), you'll need something a bit smarter. Maybe something like:That gets called like so:
or simply put, does this work (sorry its 3 years late ;) ) ?