M
mufasa
Ok! Very riddling to me. I have the following code:
#include<iostream.h>
int main(void)
{
char q[3];
char temp='a';
printf("\n%u\n",&temp);
for(int i=0;i <3;i++)
{
printf("\n%u\n",&q);
}
}
and as an output, I get a sequence of consecutive integers (addresses,
like 3122897889/90/91/92).
However, when I swap the following two lines :
char q[3];
char temp='a';
and make them
char temp='a';
char q[3];
I get an arbitrary memory location followed by 3 consecutive location
addresses. And this happens everytime I run both the versions of my
code.
How exactly is the memory allocated to the datatypes? In what order? Is
it a question worth asking?
#include<iostream.h>
int main(void)
{
char q[3];
char temp='a';
printf("\n%u\n",&temp);
for(int i=0;i <3;i++)
{
printf("\n%u\n",&q);
}
}
and as an output, I get a sequence of consecutive integers (addresses,
like 3122897889/90/91/92).
However, when I swap the following two lines :
char q[3];
char temp='a';
and make them
char temp='a';
char q[3];
I get an arbitrary memory location followed by 3 consecutive location
addresses. And this happens everytime I run both the versions of my
code.
How exactly is the memory allocated to the datatypes? In what order? Is
it a question worth asking?