Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 21-07-2007, 09:24 PM   #1 (permalink)
Apprentice
 
devilzdad's Avatar
 
Join Date: Feb 2007
Posts: 50
Default C question??


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 by devilzdad; 21-07-2007 at 10:02 PM.
devilzdad is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 21-07-2007, 09:35 PM   #2 (permalink)
In The Zone
 
Join Date: Oct 2006
Location: Mumbai
Posts: 365
Default Re: C question??

which compiler u are using?
__________________
Dhiraj Thakur
thakur.dheeraj(@)gmail.com
Desi-Tek.com is offline  
Old 21-07-2007, 09:39 PM   #3 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Default Re: C question??

Quote:
Originally Posted by devilzdad
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.....
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 21-07-2007, 09:52 PM   #4 (permalink)
In The Zone
 
Join Date: Oct 2006
Location: Mumbai
Posts: 365
Default Re: C question??

@shirish_nagar have a look at this line
Quote:
printf("%d %d", sizeof(ptr1),sizeof(ptr1));
so it should return the value of ptr1 twice
but it is returning error on my compiler
__________________
Dhiraj Thakur
thakur.dheeraj(@)gmail.com

Last edited by Desi-Tek.com; 21-07-2007 at 10:15 PM.
Desi-Tek.com is offline  
Old 21-07-2007, 10:06 PM   #5 (permalink)
Apprentice
 
devilzdad's Avatar
 
Join Date: Feb 2007
Posts: 50
Default Re: C question??

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"
devilzdad is offline  
Old 22-07-2007, 07:16 PM   #6 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,923
Default Re: C question??

hey...

devilzdad edited post last night...

Now look this...

Quote:
printf("%d %d", sizeof(ptr1),sizeof(ptr2));
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
one question here?? SUKHI99 Software Q&A 1 29-03-2007 11:38 PM
C & C++ question n2casey Programming 16 05-03-2007 01:23 PM
a RAM question anarchy0x Hardware Q&A 8 11-01-2007 09:49 AM
one question pls.... mayneu QnA (read only) 2 08-11-2006 10:54 PM
My question Official Techie QnA (read only) 6 30-10-2006 10:36 AM

 
Latest Threads
- by ico
- by Piyush
- by icebags
- by clinton
- by Charan

Advertisement




All times are GMT +5.5. The time now is 12:09 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2