Results 1 to 6 of 6
can nY1....??? tEll mE tht DATA TYPES in LINUX = 4
if nt understood : try 2 execute this .c programe in ur vi editor:
step 1: open terminal
step ...
- 02-04-2008 #1
Data Types
can nY1....??? tEll mE tht DATA TYPES in LINUX = 4
if nt understood : try 2 execute this .c programe in ur vi editor:
step 1: open terminal
step 2: type vi followed by filename & give extension as .c. ex vi ppp.c
step 3: type d matter as follows:
step 4: #include<stdio.h>
main ()
{
printf("Max size of Integer Data Type is %d",INT_MAX());
}
step 5: above program should execute bt dnt knw y its gettng executed whn
printf statement is changes to :
step 6: printf("Max size of integer Data Type is %d",size of (a);
step 7: rest all remains d same if u execute by pressing esc & save by
command :wq thn press enter
step 8: u come 2 vi editor in tht type gcc ppp.c
step 9: if u didnt get ny error its well nd good then final step 2 execute
step 10: type ./a.out thn press enter
plz ny1 ans me y it shows 4 in linux & 2 in windows ...!! thX In adv.....!!
- 02-04-2008 #2
Hi and Welcome !
I would suggest you to post in properly instead of using abbreviations. Its hard to understand what have written. English is not a native language of a lot of Members, including me.It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 02-04-2008 #3Well said. There's more wrong with that post than just the English, but since we've been letting the poor chap twist slowly in the wind for six hours, it's time for a little mercy. :)I would suggest you to post in properly instead of using abbreviations.
A shred of a clue to what he wants is in his final line:
Through the haze comes the awful truth: He's asking about sizeof(int).plz ny1 ans me y it shows 4 in linux & 2 in windows ...!!
Well, ajay2nokia, type int is a two-byte integer on some C compilers and a four-byte integer on others, for historical reasons. If you want a type that's four bytes on most C compilers, I suggest you use long instead of int. If you want two byes, use short.
Hope this helps. And please, next time, don't make us jump through all these linguistic hoops, ok?--
Bill
Old age and treachery will overcome youth and skill.
- 02-04-2008 #4
yeah thX a lot 2 bOth..!! you are quite close 2 my Q....!!
bUt my m@M asked me why int data types in linux is 4 where as int data type in win is 2....??? why...?? ThX
- 02-04-2008 #5
Please stop using abbreviations. It makes your questions very hard to understand. Just write out your English in full words, please.
To answer your question: the int datatype was designed to be exactly one word, where a word is the amount of data that a CPU register can hold. Nowadays, many words are 32 bits (4 bytes), but in the past, words were 16 bits (2 bytes), and of course, with the coming of 64-bit processors, we are seeing words of 64 bits (8 bytes). However, because of the history of this datatype, ints can really hold any size. I believe that a C int is required to be at least 16 bits, but as far as I know, there is no other assurance except that a signed int can hold any value from INT_MIN to INT_MAX, and an unsigned int can hold any value from 0 to UNIT_MAX.DISTRO=Arch
Registered Linux User #388732
- 02-06-2008 #6


Reply With Quote