将char数组参数传递给function [英] Pass char array arguments to function

查看:124
本文介绍了将char数组参数传递给function的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好吧

我需要知道如何传递char数组的元素,例如

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]

到它取一个整数和数组的函数,我的函数是

run_single_zone(argc,argv []);

谢谢所有

................. .................................................. .................................................. .................................................. ..



我的尝试:



i不知道非常

........................................ .................................................. .................................................. .................................................. .................................................. ............

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
............................................................................................................................................................................................................................................................

推荐答案

当您使用C ++时,您可能听说过 main 函数 - 应用程序的入口点......

现在,如果你看一下主要文件 [ ^ ],您将看到它能够接收字符串数组......

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...
int main (int argc, char* argv[])



从那里你可以知道 run_single_zone 的签名应该是这样的:


From there you can learn that run_single_zone's signature should be something like this:

run_single_zone(int argc, char* argv[]);





(总是很好看的您正在使用的语言的文档...就像关于点的章节一样ers和数组)



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


这篇关于将char数组参数传递给function的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆