-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
je****@gmail.com wrote:
thanks a lot Lew Pitcher.
You're welcome.
one more doubt i have it is: we are declaring a structure and the
memory for that structure will be allocated only when i creat some
objects to that one right?
You have the concept correct.
so where the momory will be allocated for structure signature and for
objects?
You have asked two questions here. Lets separate them so that the answers will
be clear.
Q1: Where will the memory be allocated for the structure definition?
Q2: Where will the memory be allocated for a specific declaration of an object
of a particular structure?
Question 1 is fairly simple: there is no memory allocated to a structure
definition. Period.
Question 2 is a little more complicated, and can be answered in several ways.
The pedants here might take exception to my answer, and they will provide
better, more accurate responses.
a) It depends. More specifically, it depends on whether you declare the object
as a static, an auto, or an extern, and it depends on whether or not you
provide an initializer for the contents of the object.
b) C makes no distinction between BSS and DATA. In fact, those terms have
nothing to do with C as a language. They /do/ have to do with the
implementation of your local C compiler on your local system, though. The best
we can tell you is that if you declare the object as 'static', the language
guarantees that the object will reside in the space set aside for 'static'
objects, and if you declare the object as 'auto', then the object will reside
in the space set aside for 'auto' objects. These two spaces /may/ be the same
physical space, or may be different physical spaces - that's beyond the
definition of the language.
i will be thankfull if you or someone clarify this one too
HTH
- --
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
- ---------- Slackware - Because I know what I'm doing. ------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Armoured with GnuPG
iD8DBQFGVGD8agVFX4UWr64RAvI1AJ0VOhE1JKZqn7IvR1QdTi DkR9nGxgCfaqkp
qhejG0h7hHuEs8USxsC5h7I=
=deLg
-----END PGP SIGNATURE-----