I'm working on simulating computer networks using "NS2 Simulator". I don't really understand why we should use const char* const* argv
instead of char *
?
Can I use char *
instead of that? There are many QA about this subject but I've confused about that. Don't mark this question as "Duplicate", please .
why we use const char* const* argv
in the function below? is this a rule in c++ standard? can i use either string
or char **
instead of that?
Function Connector::command.
//~ns/common/connector.cc
int Connector::command(int argc, const char*const* argv)
{
Tcl& tcl = Tcl::instance();
...
if (argc == 3) {
if (strcmp(argv[1], "target") == 0) {
...
target_ = (NsObject*)TclObject::lookup(argv[2]);
...
}
...
}
return (NsObject::command(argc, argv));
}
argv
is the typical argument tomain
, then it should bechar**
, notchar*
and notconst char* const*
. – Latiaconst char* const* argv
means, I highly recommend you read this. As mentioned above, standard C mandates the second argument ofmain
to be of typechar**
. – Shopwornchar* argv[]
would also work, just posting this for benefit of OP. – Stamatachar**
, isn't it? – Shopworn