+ 1

{solved} Need help with this output - C language

What is the output of this code? (assuming 8 byte pointers) const char firstname[] = "dev"; const char* lastname = "programmer"; printf("%lu\n", sizeof(firstname) + sizeof(lastname)); Edit: I am not sure of this but for dev it can be 3 char each of 1byte + one \0 of 1 byte so the size is 4

28th Dec 2020, 5:50 PM
Saithama
5 odpowiedzi
+ 3
The output is the following: https://code.sololearn.com/cevQ5CQA1T9B/?ref=app For knowing an output just copy and paste it on a code playground in your profile. Btw hope that I helped you 😄 Edited: Saithama Btw sorry, I dont know, sorry for wrong understanding your question.
28th Dec 2020, 5:52 PM
Matthew
Matthew - avatar
+ 1
Coder Kitten My bad since sizeof operator has the firstname passed to it i assumed it would output the char ptr size and not the array size this was interesting!
28th Dec 2020, 7:36 PM
Saithama
28th Dec 2020, 5:52 PM
Saithama
0
MΛƬƬΣӨ Sorry I meant how do we arrive at the output? what does 8byte (64bit) pointer mean? Edit: No issues I am not sure of this but for dev it can be 3 char each of 1byte + one \0 of 1 byte so the size is 4 but i dont understand how its done for programmer
28th Dec 2020, 5:55 PM
Saithama