![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Advertisements