LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-28-2004, 11:30 PM   #1
hiren
LQ Newbie
 
Registered: Sep 2004
Posts: 5

Rep: Reputation: 0
How Sizeof Operator Implemented?


Dear Memebers,

I want to know how the Sizeof Operator is implemented and also What does matter when deciding the size of Interger?

Why it is 2 bytes in Windows and 4 bytes in Linux? Is there any Hardware configuration or Is it depends upon a software(i.e. Compiler)?

Could anyone help me out? I have tried searching on Net but couldn't able to find out.

Thank you,
Hiren Gajjar.
 
Old 09-29-2004, 12:37 AM   #2
vinay_s_s
Member
 
Registered: Jul 2003
Posts: 659

Rep: Reputation: 30
hi hiren, its depends on the implementation of the OS 16 bit or 32 bit.

size of int = 1 word

1 word = 2 bytes in a 16 bit system
1 word = 4 bytes in a 32 bit system

Linux is a 32bit
DOS is 16 bit
 
Old 09-29-2004, 12:39 AM   #3
vinay_s_s
Member
 
Registered: Jul 2003
Posts: 659

Rep: Reputation: 30
oh windows is also 32 bit - get a windows compiler (borland c++ fow windows o something like that) and test it out if u want.
The turboc made for dos, runs under dos so u get 2 bytes even on dos prompt in windows
 
Old 09-29-2004, 02:47 AM   #4
hiren
LQ Newbie
 
Registered: Sep 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for your reply.

Does it means that if OS is 64 bits than int is 8 bytes? Any other factors?

Thank you,
Hiren Gajjar.
 
Old 09-29-2004, 05:12 AM   #5
-mk-
LQ Newbie
 
Registered: Jul 2004
Posts: 12

Rep: Reputation: 0
see:
http://www.flipcode.com/cgi-bin/msg....3dtheory&id=-1

-mk-
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
sizeof and malloc in C exvor Programming 4 08-07-2005 12:06 PM
sizeof operator implementation vinods Programming 1 10-26-2004 09:57 AM
when does sizeof ( ) operator return zero !! joeyBig Programming 3 10-01-2004 06:43 AM
Sizeof Operator Implementation hiren Programming 4 09-28-2004 10:32 AM
sizeof() and C/C++ boku Programming 2 09-01-2002 07:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration