C question??

Status
Not open for further replies.

devilzdad

Broken In
void main()
{
char far *ptr1,*ptr2;

printf("%d %d", sizeof(ptr1),sizeof(ptr2));
}

The output look like 4 2 why not it become 4 4.


Note: sorry guys its "sizeof(ptr2)"
 
Last edited:

Garbage

God of Mistakes...
devilzdad said:
void main()
{
char far *ptr1,*ptr2;

printf("%d %d", sizeof(ptr1),sizeof(ptr1));
}

The output look like 4 2 why not it become 4 4.


I think it is bcoz the "far" is only for ptr1 & NOT for ptr2.

i.e. char far *ptr1, *ptr2;

Correct me if I'm wrong.....
 

Desi-Tek.com

In the zone
@shirish_nagar have a look at this line
printf("%d %d", sizeof(ptr1),sizeof(ptr1));
so it should return the value of ptr1 twice
but it is returning error on my compiler
*img408.imageshack.us/img408/3245/dnsim6.th.jpg
 
Last edited:
OP
devilzdad

devilzdad

Broken In
guys i'm using Turbo C......

i got the answer 4, 2.....

but i'm not understanding the reason for dat??

its the first question in " Test your C skills-yeshwant kanetkar"
 
Status
Not open for further replies.
Top Bottom