int foo[5];
What is the type of foo? You should know this.
int foo[5];
What is the type of foo? You should know this.
foo is a pointer to an int array of size 5.
in C
>foo is a pointer
Whoops! Would you like to try again?
*foo is equivalent to foo[0]
*(foo + 4) is equivalent to foo[4]
so yes, it's a pointer.
"array of 5 integers"
What is the point of this thread?
arrays are convertibles to pointers through a standard conversion but aren't pointers.
>Can be dereferenced like pointers
FTFY
foo is an array of 5 ints.
So, of course, &foo is a pointer to an array of 5 ints.
Try running
printf("%p %p %p %p", foo, foo + 1, &foo, &foo + 1);
int foo[5];
foo[0] = 2;
printf("%d %p %p", *foo, foo, &foo);
2 0x7ffecdb99b00 0x7ffecdb99b00
>I don't know what decay is
The type is "array of 5 int".
fcking retards
foo is pointer, array is only imaginary word
foo points to address based on [x] as foo + type * x
&foo is a reference
*fpointer = &foo is a pointer
>array is only imaginary word
wow, it's not even a real word? Look at that!
its type is
>sub esp, 5*sizeof(int)
Arrays are automatically passed as a ref went sent as a parameter to functions..
And what about foo + 1 and &foo + 1? In this example they should end in 9b04 and 9b14 respectively.
Foo+1 4 bytes
Foo+2 10 bytes
M'kay
Use sizeof senpai, you'll be surprised
Use vectors
Stop using C.
printf("sizeof(int): %d\n", sizeof(int));
printf("sizeof(int*): %d\n", sizeof(int *));
printf("sizeof(int **): %d\n", sizeof(int **));
int foo[5];
foo[0] = 2;
printf("%d %p %p %p %p\n", *foo, foo, &foo, foo+1, &foo+1);
2 0x7ffc80a982c0 0x7ffc80a982c0 0x7ffc80a982c4 0x7ffc80a982d4
fuck forgot the rest
sizeof(int): 4
sizeof(int*): 8
sizeof(int **): 8
I don't you did that correct
Wouldn't it make sense that a pointer is 64 bits on a 64bit arch? Int is only guaranteed to be between char and long
>this thread
you really need to find more interesting things to argue about
Arrays and pointers are actually slightly different in C. In C an array also has information about the number of elements if it was allocated on the stack. This allows you to use sizeof(array)/sizeof(array[0]) to get the number of elements in the array. This only works on arrays and not pointers as the size of a pointer is just whatever size your machine uses (32 or 64 bits).
I know it's type is int[5], but only because I saw some of the retarded sycophants on #C on freenode pitch a fit about it once to satisfy one of that channel's admins.
*its
fucked that up, was originally going to type "it's int[5]"...