Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

sizeof expertise

Name: Anonymous 2011-12-17 5:16

    int *p;
    int a[1000];


If a and p are exactly the same fucking thing (a pointer to an integer), why do sizeof p and sizeof a differ?

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2011-12-17 5:30

sizeof a = 1000*(sizeof p)

This is one of the few areas where arrays and pointers differ.

Name: Anonymous 2011-12-17 5:58

>>1
sizeof assumes you're using a pointer to point at just one location of data and gives you the pointer size. When using an array, you probably aren't interested in the pointer it really represents. Remember, it's an operator, not a function; the behaviour can get pretty weird.

>>2
This is a coincidence -- sizeof(p) is uintptr_t (usually 4), sizeof(a) is 1000 * sizeof(int) (usually 4000). If these were char *p and char c[1000], results would be 4 and 1000, for example.

Name: Anonymous 2011-12-17 6:19

stop trolling

Name: Anonymous 2011-12-17 7:11

Except they are not.
p is a pointer, a is a statically allocated array

go back to /g/, please.

Name: Anonymous 2011-12-17 7:23

>>5
Example of good answer: http://www.lysator.liu.se/c/c-faq/c-2.html#2-3
Example of decent answer: >>3
Example of mediocre yet passable answer: >>2
Example of shitposting: your post and >>4

Name: Anonymous 2011-12-17 7:52

Let's not have this discussion ever again.

Don't change these.
Name: Email:
Entire Thread Thread List