#Datatypes and their sizes!

1 messages · Page 1 of 1 (latest)

near maple
#

I somehow don't see the difference! Why do both of them behave differently?

#include <stdio.h>

int main() {
    printf("%lld", sizeof("a")); // sizeof = 2
    printf("%lld", sizeof(char)); // sizeof = 1
}
fading pollenBOT
#

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 use !howto ask.

viral onyx
#

"a" is an array of 2 characters.

near maple
viral onyx
#

Yes but with single quotes.

dapper rapids
#

<pendantic mode="on">
The format specifier for size_t is "zu", so technically it should read

printf("%zu", sizeof(something));

</pedantic>

near maple
near maple
#

!solved