Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi every body
I need to know how I can pass an char array's elements such as
argv[0] = "./run_single_zone"
argv[1] = "data_pub/my_net.xml"
argv[2] = "data_pub/zone.xml"
argv[3] = "my_output.xml"
argv[4] = "[z <= 10]"
to the function which it take an integer and array, my function is
run_single_zone(argc, argv[]);
thanks all
.........................................................................................................................................................................

What I have tried:

i don't know very much
............................................................................................................................................................................................................................................................
Posted
Updated 9-May-16 4:00am
Comments
Sergey Alexandrovich Kryukov 9-May-16 9:58am    
It would be easy to do (just learn C++, to start withl you are not even trying to use C++ syntax, forget the functionality), but the name "argv" suggests much worse thing: you don't understand what you want. Is it an argument of the function main? If so, this is the data you receive from the user, not "pass". If this is something else, please explain.
—SA
Member 12512031 9-May-16 10:05am    
i had this function run_single_zone and i need to pass 2 arguments
the first one is argc which is the number of the array parameters here it's 5
and the other is an array[5] so inside the function it will check the number of parameters and do the calculation

1 solution

As you are working with C++, you probably heard of the main function - the entry point of your application...
Now if you look at the documentation of main[^], you will see that it is able to receive an array of strings...
C++
int main (int argc, char* argv[])

From there you can learn that run_single_zone's signature should be something like this:
C++
run_single_zone(int argc, char* argv[]);


(It is always good to read the documentation of a language you are using...like the chapters about pointers and arrays)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900