关于在main func中定义的另一个函数中命令行参数的用法 [英] About usage of command line arguments in another function defined out of main func
问题描述
如何在main函数中调用并在main函数外部定义的函数中使用命令行参数。即使我可以将它们作为参数传递。但是,如果我这样做...它让我传递了许多论点。所以,请让我知道如何在另一个函数中获取cmnd行参数,而不将它们作为参数传递给函数。
如何在调用的函数中使用命令行参数main函数并在main函数外部定义。即使我可以将它们作为参数传递。但如果我这样做...它会让我传递许多参数。所以,请让我知道如何获取cmnd行参数在另一个函数中,不将它们作为参数传递给函数。
您可以实现一个全局单例对象,该对象包含命令的副本
行参数。 main()函数应该做的第一件事就是创建一个单独的
实例。所有其他函数都可以访问实例以获取
命令行参数的值。
亲切的问候,
Jos
如何在main函数中调用并在main函数外部定义的函数中使用命令行参数。即便如此,我可以将它们作为参数传递。但如果我这样做...它会让我传递许多参数。所以,请让我知道如何在另一个函数中获取cmnd行参数而不将它们作为参数传递到功能。
主要功能的原型是
展开 | 选择 | Wrap | 行号
主函数的原型是
展开 | 选择 | Wrap | 行号
Hi,
How do i use command line arguments in the function which is called in main function and defined outside the main function.Even though,i can pass them as arguments..but if i do that...it makes me to pass many arguments.So,please let me know how do i fetch the cmnd line arguments in another function without passing them as parameters to the function.解决方案Hi,
How do i use command line arguments in the function which is called in main function and defined outside the main function.Even though,i can pass them as arguments..but if i do that...it makes me to pass many arguments.So,please let me know how do i fetch the cmnd line arguments in another function without passing them as parameters to the function.You could implement a global singleton object that holds a copy of the command
line arguments. The first thing a main() function should do is create such a single
instance. All other functions can access the instance for the value(s) of the
command line arguments.
kind regards,
Jos
How do i use command line arguments in the function which is called in main function and defined outside the main function.Even though,i can pass them as arguments..but if i do that...it makes me to pass many arguments.So,please let me know how do i fetch the cmnd line arguments in another function without passing them as parameters to the function.The prototype for the main function is
Expand|Select|Wrap|Line Numbers
The prototype for the main function is
Expand|Select|Wrap|Line Numbers
这篇关于关于在main func中定义的另一个函数中命令行参数的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文登录 关闭
扫码关注1秒登录发送“验证码”获取 | 15天全站免登陆