Ибраги́м
Pavel
true, in the above example why argv is of type char **. and what that means?
char** is basically a pointer to memory where char* lies. It doesn't say if there are other pointers or how many. As for array with empty [] on low level it's the same pointer. Array with a size is created on stack, not in the heap, and threated differently by compiler.
Daniele°
true, in the above example why argv is of type char **. and what that means?
argv is char** because is an Array of string. String in C are Array. Array in C is * And now have char**
Pavel
an English speaking Russain, with arabic profile. seems funny😊
By the way, why you started from pure C? Why not C++ with its std::array, std::vector and other pretty things? Is it some requirements from your university?
Pavel
I have nothing against learning C, but it's much more low-level than modern C++
Daniele°
Mihail
argv is char** because is an Array of string. String in C are Array. Array in C is * And now have char**
> Array in C is * No that's false. Arrays do decay into pointers, but they aren't pointers
Daniele°
But [] is equal to * char* v[] Is char** v
Daniele°
For this reason have write array is *
Daniele°
int main(int count, char* args[]) And int main(int count, char** args) they are the same thing
Daniele°
Actually they are not
In this case are identical
Jussi
https://stackoverflow.com/questions/10186765/what-is-the-difference-between-char-array-vs-char-pointer-in-c
Jussi
Yes
Jussi
But some may think that generally char* and char [] are same
Daniele°
[N] create Array and isn't identical to *
Daniele°
Compiler not know symbol []
Ибраги́м
Daniele°
Compiler translate [] to * And a[1] Is *(a+1) For demostrate this you can build this code without problem int a[10]; 1[a]=0;
Daniele°
Difference between Array and pointer is only in declaration. int a[10]; int* b; a is an Array than reserve space in stack. b is only a pointer.
Jussi
Difference between Array and pointer is only in declaration. int a[10]; int* b; a is an Array than reserve space in stack. b is only a pointer.
No, actually not. char* a = "1234"; char b[] = "1234"; sizeof(a) returns 4 or 8 depending on 32/64bits, sizeof(b) returns 5
Jussi
Difference is not in declaration only
Jussi
Yes ofc
Daniele°
You can't in a function arguments
Daniele°
void foo(char z[]) Z not reserve space for Array and is Always only a pointer
Ибраги́м
Because C > C++
U mean C != C++
🐰🐾 سمیه
Call me the Mystery Man.
Call you weirdo 😂
Mihail
In this case are identical
In this context they might have the same effect, but that doesn't make them the same thing
Ибраги́м
Call you weirdo 😂
You are the one learning C tho
Mihail
You are the one learning C tho
Learning to later have to unlearn lol
Mihail
compiler not know []
If it didn't that code won't compile lol
Mihail
And it does
Anonymous
I have nothing against learning C, but it's much more low-level than modern C++
You seem to tell this like knowing a low-level programming language is something bad
Daniele°
Ибраги́м
Learning to later have to unlearn lol
I pity the young woman, by the time she's done, her kids are already writing C++29
Mihail
can build because translate to *
can build because translate to * based on the context that [] is used in
Mihail
That I can agree with
Mihail
But it pretty much makes your initial statement invalid
Daniele°
So?
This works because compiler not know []
Anonymous
C is bad-level programming.
And you're gonna explain I guess?
Mihail
If it didn't how would it compile it?
Ибраги́м
Anonymous
Is this bot
Daniele°
Yes it does lol
1[a] translate to *(1+a) a[1] to *(a+1)
Mihail
1[a] translate to *(1+a) a[1] to *(a+1)
So what does int a[10]; translate to?
Ибраги́м
Daniele°
So what does int a[10]; translate to?
It's unique difference
Mihail
Hint: it fucking doesn't
BinaryByter
in this end this querrel is pointless
Daniele°
Exactly
But in this case not allocate memory
BinaryByter
both syntaxes are valid
BinaryByter
doesnt matter what the compiler sees in them
BinaryByter
in the end, one will be evaluated to some space reserved on the stack or in the heap
Daniele°
on function argument you can't allocate array
BinaryByter
the other will result in some pointer arithmetic
BinaryByter
In C?
myFunc (malloc(sizeof(myObject)))
Mihail
the other will result in some pointer arithmetic
And are those two things the same in your world? Because for me no they aren't
Mihail
Exactly
BinaryByter
they are inherently different
Daniele°
void foo(int z[10]); Z is simple pointer, not allocate memory
Anonymous
Wrong question.
Not sure what you referred to, though. Bother to explain your statement?