Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Additional information:
It shows you the number of bytes that will be assigned in memory. With this information can you calculate the length of an array.
e.g.
int x[5];
size_t y = sizeof(x) / sizeof(int);
-> 5 = 20 / 4
It‘s the Common way for calculate the length.
The main problem by calculating is that you don’t know how many bytes assign in memory on your target system. For example on some micro controllers a „long“ type has 4 bytes and the „int“ type has also 4 or only 2 bytes. -
@Fast-Nop
Cppreference is the second link i get, when I search for c sizeof on duck duck go.
what is sizeof() in c?
question