pointer concept

K

karthikbalaguru

Such questions don't have simple answers. If the compiler can detect
that 'p' is not required, it may not actually allocate any memory at
all. It is even possible (depending on the context) that the compiler
might eliminate the string literal!

Interesting way of thinking :):)

Karthik Balaguru
 
R

Richard Heathfield

Keith Thompson said:
If there's no generated code, then the amount of allocated space is
zero (though it's still the same in the abstract machine).

C can be interpreted. Interpreters do not (necessarily) generate code in
the sense of an object file that you can examine. So do C interpreters run
their programs in 0 memory?
 
R

Richard Heathfield

CBFalconer said:
The literal may not be needed. For example:

char *o = "First str";
char *p = "str";

in which *p may well point to the "str" portion of "First str".

That's actually a good example of the string literal needing more than four
bytes.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top