
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
What does int argc, char *argv[] mean in C/C++?
argc stands for argument count and argv stands for argument values. These are variables passed to the main function when it starts executing. When we run a program we can give arguments to that program like −
$ ./a.out hello
Example
Here hello is an argument to the executable. This can be accessed in your program. For example,
#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
Output
This will give the output −
This program has 3 arguments
C:\Users\user\Desktop\hello.exe hello people
Note that the first argument is always the location of the executable executing.
- Related Articles
- What does int argc, char *argv[] mean in C++?
- What does INT(7) in MySQL mean?
- How do I convert a char to an int in C and C++?
- What does “dereferencing” a pointer mean in C/C++?
- How to convert a single char into an int in C++
- What does the operation c=a+++b 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 [Flags] Enum Attribute mean in C#?
- What does the method addAll(int, Coll C) do in java?
- What is difference between int and const int& in C/C++?
- C++ Program to find size of int, float, double and char in Your System
- What does 'using namespace std' mean in C++?
- What does the two question marks together (??) mean in C#?

Advertisements