
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
What does int argc, char *argv[] mean in C++?
The argc stands for argument count and argv stands for argument values. These are variables passed to main function when it starts executing. When we run a program we can give arguments to that program like:
$ ./a.out hello
Here hello is an argument to the executable. This can be accessed in your program.
Example Code
#include<iostream> using namespace std; int main(int argc, char** argv) { cout << "This program has " << argc << " arguments:" << endl; for (int i = 0; i < argc; ++i) { cout << argv[i] << endl; } return 0; }
When you compile and run this program like:
$ ./a.out hello people
This will give the output:
This program has 3 arguments
Output
C:\Users\user\Desktop\hello.exe hello people
- Related Articles
- What does int argc, char *argv[] mean in C/C++?
- What does INT(7) in MySQL mean?
- How to convert a single char into an int in C++
- How do I convert a char to an int in C and C++?
- What does the method fill(int[], int fromIndex, int toIndex, int val) do in java?
- What does “dereferencing” a pointer mean in C/C++?
- What does the explicit keyword mean in C++?
- What does the restrict keyword mean in C++?
- What does the volatile keyword mean in C++?
- What does the method sort(int[] a, int fromIndex, int toIndex) do in java?
- What does the method copyOfRange(int[] original, int from, int to) do in java?
- What does the method fill(int[], int val) do in java?
- What does the method addAll(int, Coll C) do in java?
- What does the operation c=a+++b mean in C/C++?
- What does the [Flags] Enum Attribute mean in C#?

Advertisements