Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An Analysis of the error-prone questions of argc,argv and CumberCraft +

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "argc,argv and C/C++ easy wrong problem analysis", the explanation content in the article is simple and clear, easy to learn and understand, please follow the small series of ideas slowly in-depth, together to study and learn "argc,argv and C/C++ easy wrong problem analysis" bar!

argc is argument count. As the name suggests, is the number of parameters entered by the user on the command line.

argv is argument vector. is the vector library of parameters entered by the user (array)

int main(int argc ,char *argv[])

char *argv[] is a pointer array ([] has higher priority than *, so each element in it is char* type, to understand the difference between char (*argv)[] and char *argv[]), each element, stored are parameters, these parameters are strings. It's actually a vector library. If you don't understand this for a while, don't worry, look down.

It actually records the parameters passed in when the program is executed. Including the statement that opens the program. If I save a program called test.exe, execute it on the command line with a few parameters:

test.exe x y z

In this case, argc is four parameters, namely text.exe, x, y, z. The output would look like this:

Code:

#include

using namespace std;

int main(int argc, char* argv[]) {

cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report