Structure

J

Jake Thompson

Do you need to allocate a structure before you use it if it only holds
one instance and is not in array format?
 
P

pemo

Jake Thompson said:
Do you need to allocate a structure before you use it if it only holds
one instance and is not in array format?

How could you use it if it isn't declared/defined?
 
B

Benry

Only if it contains a pointer, or anything that takes up memory. If a
struct just has an int or something in it, you don't have to allocate
any memory.
 
D

Default User

Jake said:
Do you need to allocate a structure before you use it if it only holds
one instance and is not in array format?

What do you mean by "allocate". Please give an example.



Brian
 
K

Keith Thompson

Benry said:
Only if it contains a pointer, or anything that takes up memory. If a
struct just has an int or something in it, you don't have to allocate
any memory.

Context is important; please read <http://cfaj.freeshell.org/google/>.

Of course you have to allocate memory for it. You can do so either by
calling an allocation function such as malloc(), or by declaring an
object (which implicitly allocates memory).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top