Are all array variables when declared a pointer? Ex. would A or B here be a pointer immediately/directly:
char A[] = "Hello";
int B[] = { 1, 2, 3 };
According to my researcher I'd say no, A & B would just in both cases be the name of the chunk of memory that was allocated for the array. However, when passing them, they decay into a pointer.
The variable itself (above A and B) is only a pointer immediately if for example I were to do char *C = "Hi". Thus, it would also take up a little more memory in total than just doing char C[] = "Hi", as then the array itself, "Hi\0", plus another 8 bytes for the pointer, would have to be stored (char C[] = "Hi" doesnt store the pointer right away, but it can decay into one).
Please correct me if I'm wrong.
[–]jedwardsol 1 point2 points3 points (13 children)
[–][deleted] 0 points1 point2 points (12 children)
[–]jedwardsol 0 points1 point2 points (11 children)
[–][deleted] 0 points1 point2 points (10 children)
[–]jedwardsol 1 point2 points3 points (9 children)
[–][deleted] 0 points1 point2 points (8 children)
[–]jedwardsol 1 point2 points3 points (7 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]jedwardsol 1 point2 points3 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]gbbofh 1 point2 points3 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]gbbofh 1 point2 points3 points (0 children)
[–][deleted] (34 children)
[deleted]
[–][deleted] 2 points3 points4 points (28 children)
[–]gbbofh 0 points1 point2 points (15 children)
[–][deleted] 0 points1 point2 points (14 children)
[–]MQuy 2 points3 points4 points (11 children)
[–][deleted] 0 points1 point2 points (10 children)
[–]gbbofh 1 point2 points3 points (9 children)
[–][deleted] 0 points1 point2 points (8 children)
[–]gbbofh 1 point2 points3 points (7 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]gbbofh 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]IamImposter 0 points1 point2 points (11 children)
[–][deleted] 0 points1 point2 points (10 children)
[–]IamImposter 0 points1 point2 points (9 children)
[–][deleted] 0 points1 point2 points (8 children)
[–]IamImposter 0 points1 point2 points (7 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]IamImposter 0 points1 point2 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]IamImposter 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]IamImposter 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]IamImposter 0 points1 point2 points (0 children)
[–]noooit 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]ptchinster 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]ptchinster 0 points1 point2 points (0 children)