Values stored in char *argv[]

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


if(argc != 5)
{
oops: exit(0);
}

if(strlen(argv[1]) != 3)
{
fprintf(stderr, "\nError --- must specify 3 rotors\n");
goto oops;
}


argc and argv[] are declared in main.

when coming to if condition what will be in argv[]? what does it mean and how it works? can any one help me in it?
what will be in argv[]?

argv[] is an array of pointers to const char.

argv[1] is a pointer to a const char.

This is one of the programs i have seen.

there is nothing in argv[].
closed account (z05DSL3A)
There is always something in argv[]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <string>

using namespace std;

int main(int argc,const char *argv[])
{
    cout << "argc=" << argc << endl;
    
    for (int i=0; i < argc; i++) 
    {
        cout << "argv[" << i << "]=" 
             << argv[i] << endl;
    }
    return(0);
}
Topic archived. No new replies allowed.