Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

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

Shulou Source: shulou.com Published: 2022-06-01 19:11:04 09月11日 Update

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

Tags: Parameters answers that is wrong questions analysis programs numbers levels expressions learning output elements content variables commands actually arrays users results Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Information macOS vpn MariaDB