473,388 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

sizeof(int) and sizeof(long int)

Hi to everyone,

I exexuted sizeof(int) and sizeof(long int) and I got the result ¨4¨ from both. I´m using the gcc 3.3.5. Shouldn´t sizeof(long) produce ¨8¨? Am I doing something wrong?

Thanks
Spyros
Sep 18 '05 #1
1 22171
No nothing is wrong. The size of data-types is generally hardware dependant (exception being char which is always 1 register wide). In gcc/Unix, int and long int both require 4 bytes. You can also try sizeof(long long int) and see the results and sizeof(short int).
Nov 16 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

70
by: Roy Yao | last post by:
Does it mean "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" ? According to my analysis, operator sizeof, (type) and * have the same precedence, and they combine from right to left. Then this...
28
by: Richard Cavell | last post by:
Hi, Is there some kind of canonical list, or would someone like to give a brief rundown, as to: sizeof(int) sizeof(long int) sizeof(long long) etc
4
by: Lingyun Yang | last post by:
*** post for FREE via your newsreader at post.newsfeed.com *** Dear all, I have a file it's binary data viewed in UltraEdit is EF BB BF 0D 0A 3C ....... I want to read them into a int or long...
2
by: blufox | last post by:
I read somewhere that standard Ansi C on 32 bit architecures assumes a lot of things which lead to poor code. For example sizeof( int ) = sizeof( void * ) sizeof( long ) = sizeof( int ) Why...
56
by: write2gops | last post by:
Hi, Is there a way to change the sizeof int type? Is it posible to make it return 3 or 5 by changing some header file in the compiler? Thanks in advance.
5
by: Francois Grieu | last post by:
Does this reliably cause a compile-time error when int is not 4 bytes ? enum { int_size_checked = 1/(sizeof(int)==4) }; Any better way to check the value of an expression involving sizeof...
40
by: Spiros Bousbouras | last post by:
Do you have an example of an implementation where sizeof(short int) does not divide sizeof(int) or sizeof(int) does not divide sizeof(long int) or sizeof(long int) does not divide sizeof(long long...
12
by: aarklon | last post by:
Is y >(8 * (sizeof(int) -1)) portable expression to find The MSB of an unsigned integer y ?? will this work in all the cases, all three of the representations C allows: 1) two's complement...
5
by: aarklon | last post by:
Hi all, why printf("....%d",sizeof((int)(double)(char) i)) always gives the size of int ??? is it because sizeof doesn't evaluate its operand....???
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.