!!!argc and argv as parameter of main function
2013-09-16 23:00
363 查看
Definition
http://stackoverflow.com/questions/3024197/what-does-int-argc-char-argv-meanargvand
argcare how command line arguments are passed to
main()in C and C++.
argcwill be the number of strings pointed to by
argv. This will (in practice) be 1 plus the number of arguments, as virtually all implementations will prepend the name of the program to the array.
The variables are named
argc(argument count) and
argv(argument vector) by convention, but they can be given any valid identifier:
int main(int num_args, char** arg_strings)is equally valid.
They can also be omitted entirely, yielding
int main(), if you do not intend to process command line arguments.
Practice
#include <stdlib.h> int main(int argc, char* argv[]) { printf("Have %d arguments", argc); for (int i = 0; i<argc; ++i) { printf("%s \n", argv[i]); } }
Provide arguments: a1 b2 c3
output is:
Have 4 arguments ./Test // the full path to the Test project dsfds sdf 3 Program ended with exit code: 0
How to provide these parameters in Xcode
http://stackoverflow.com/questions/1454587/passing-arguments-to-main-function相关文章推荐
- The meaning of "argc" and "argv" in programming
- [Swift] function pointer(address) as the parameter of function
- Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
- relying on packaging to define the extension of the main artifact has been deprecated and is schedul
- argc and argv
- UTL_HTTP Call a Web Service and Pass Parameters as Part of the URL
- Undefined function 'conv2' for input arguments of type 'double' and attributes 'full 3d complex'.
- 【转帖】UFLDL Tutorial(the main ideas of Unsupervised Feature Learning and Deep Learning)
- error C2733: second C linkage of overloaded function '_interlockedbittestandset' not allowed
- main(argc,argv) 中的参数
- error c2733: second C linkage of overloaded function '_interlockedbittestandreset" not allowed
- main 函数的 参数 argc,argv 用法
- A simple visualization of energy function and energy gap in hopfield nets
- main 函数参数中 argc/argv的相关讨论和使用
- Task And Function (of Verilog HDL)
- About the return value of the main function
- [Cycle.js] Main function and effects functions
- IOS警告imgName' used as the name of the previous parameter rather than as part of the selector
- use function pointer as parameter
- Running Multiple Instances of Google Talk (GTalk Polygamy) and Login as Multi Users[转]