संभव डुप्लिकेट:
size of int, long, etc
Does the size of an int depend on the compiler and/or processor?
What decides the sizeof an integer?64-बिट मशीन पर आकार (int) क्या होना चाहिए?
मैं एक 64-bit
मशीन का उपयोग कर रहा हूँ।
$ uname -m
x86_64
$ file /usr/bin/file
/usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, stripped
$
जब मैं निम्नलिखित प्रोग्राम भाग गया, मैं 4-bytes
रूप sizeof(int)
मिला है।
#include <stdio.h>
int main(void)
{
printf("sizeof(int) = %d bytes\n", (int) sizeof(int));
return 0;
}
मैं एक 16-
, 32-
और 64-
बिट मशीन चल रहा हूँ, तो यह मतलब नहीं है कि एक integer
के आकार 16-
, 32-
और 64-
बिट क्रमशः है?
मेरी मशीन में, मुझे WORD_BIT
32
मिला। मशीन पर 64
नहीं होना चाहिए?
$ getconf WORD_BIT
32
$
और, sizeof(int)
64-bits
(8 bytes
) उपरोक्त मामले में नहीं किया जाना चाहिए?
मैं एक सी व्यक्ति नहीं हूँ, लेकिन मेरा मानना है कि 'char' के अलावा कुछ के आकार संकलक-विशिष्ट है, और यह भी जरूरी प्रोसेसर पर एक शब्द का आकार नहीं है। – Ryan
http://stackoverflow.com/questions/589575/size-of-int-long-etc – Perception
@minitech: चार भी विशिष्ट – Dani