Robotnik said:
Hello All,
I want to know if we could know the size of a structyure
without the use of sizeof().
Any hints.
No. Nor is that meaningful. That's what sizeof is *for*. Various unportable
tricks suggest themselves as replacements, all of them worthless because
they're unportable tricks when a perfectly portable alternative is
available: sizeof.
If this is a homework assignment, tell the instructor to come up with better
questions.
If you have a legitimate need to know the size of a structure outside of a C
program, you can easily write a small program whose sole purpose it is to
measure a struct and write the outcome somewhere. Note that the result
depends on your platform, your compiler, the options you passed and possibly
the phase of the moon; you need to know what you are doing and why you're
doing it. Interfacing with existing binary interfaces is one possible reason.
S.