#Command line arguments
30 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
So first point, as a function argument char** argv and char* argv[] are equivalent
Second
!cdecl char const * const * argv
Damn, that command doesn't work :(
Basically it's saying that neither argv[n] or argv[n][m] can be changed
char const * const * means “pointer to const pointer to const char”
const char * const * is also the same
🧐 “pointer to const pointer to const char”
looks a bit confusing
if you try to use char** argv and then try to redirect argv[1] to something or even worse, edit the chars of argv[1], you will have a bad time
@proud silochar* argv[] = char** argv those are the same
^ not completely
nvm all the expert have already answer you
let me know what u know about the different because i always write it like that char **argv
wait nvm, due to array decaying to pointer they are literally the same
As I understand it, they are the same for function arguments, and initializing from aleady existing arrays
But as a local array, they are different
const char* argv[] = {"Hello", "world"}; // Valid
const char* argv2[] = argv; // Invalid
const char** argv3 = argv; // Valid
saying argv = NULL is the invalid part, you can't assign arrays
but you can assign to double pointers
My point being is that the types are different.
It's just that for function arguments, C just decides to treat them the same
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
so . . .
something like
char const *str1 = "abc";
char const *const str2 = str1; // const pointer to const char *str1
char const *const *str3 = &str2; // pointer to const pointer of char type str2
and just to make it simple
char ch1 = 'a';
char *ch2 = &ch1;
char **const ch3 = &ch2;
char **const *ch4 = &ch3;
is that correct ?