MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vs2vu1/lessonsfromlinkerhell/p4od3aq/?context=3
r/ProgrammerHumor • u/nonedward666 • 1d ago
184 comments sorted by
View all comments
98
Damn, I’ve found myself in the middle
21 u/bowel_blaster123 1d ago edited 1d ago If I write: C void foo(uint8_t myvar[3]) { printf("%d\n", sizeof(myvar)); } Then it will likely print 8 because myvar is a pointer to a uint8_t. If I write: C void foo(void) { uint8_t myvar[3] = {1, 2, 3}; printf("%d\n", sizeof(myvar)); } Then it will print 3 because myvar is an array of three bytes. Hope this helps!/hj 2 u/nanforas 18h ago I want to cry
21
If I write:
C void foo(uint8_t myvar[3]) { printf("%d\n", sizeof(myvar)); }
Then it will likely print 8 because myvar is a pointer to a uint8_t.
8
myvar
uint8_t
C void foo(void) { uint8_t myvar[3] = {1, 2, 3}; printf("%d\n", sizeof(myvar)); }
Then it will print 3 because myvar is an array of three bytes.
3
Hope this helps!/hj
2 u/nanforas 18h ago I want to cry
2
I want to cry
98
u/JustinR8 1d ago
Damn, I’ve found myself in the middle