Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C
Hi all,
 
what is the definition on the key word int.
How the internal working ....
 

Regards,
Shefeek
Posted 10-Jan-13 7:37am
shefeekcm2.4K
Edited 10-Jan-13 7:53am
ridoy51.9K
v2
Comments
ridoy at 10-Jan-13 12:53pm
   
How the internal working .... what does it mean?!
Sergey Alexandrovich Kryukov at 10-Jan-13 13:09pm
   
You are just wasting time. Before asking question, better prepare yourself to be a qualified inquirer, read on the topic, ask a question only if you feel you stuck.
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

An integer(int) type variable is a variable that can only hold whole numbers (eg. -2, -1, 0, 1, 2).An int is either 2 or 4 bytes .
See details from here..
http://www.learncpp.com/cpp-tutorial/24-integers/[^]
  Permalink  
Comments
PIEBALDconsult at 10-Jan-13 13:31pm
   
Really? I seem to recall putting characters in an integer on occasion.
JackDingler at 10-Jan-13 17:23pm
   
A char is simply an 8 bit int.
Or one byte...
PIEBALDconsult at 10-Jan-13 19:56pm
   
Oh, but it's so much more. And when I put four of them in an int, boy now we're talkin'.
nv3 at 10-Jan-13 14:36pm
   
Your answer is not entirely correct. An int can have other sizes than just 2 or 4 bytes, depending on the computer architecture. 2 and 4 bytes are common sizes on 16- and 32-bit archtecture though. And your answer certainly deserves more than a 1.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

for example: in 16 bits OS int is 2bytes, in 32 bits OS int is 4 bytes.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

An int is defined as a signed value of whatever size a particular compiler decides is reasonable. If I remember correctly, it must be at least 16-bit.
 
The standard defines only that:
 
sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) (etc. other variant's depend on support, e.g. __int64, long long)
 
(sizeof(t) is the size (in bytes) of the type t supplied)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Mathew Soji 330
1 BillWoodruff 260
2 Sergey Alexandrovich Kryukov 240
3 OriginalGriff 216
4 Afzaal Ahmad Zeeshan 208
0 OriginalGriff 6,168
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,028
3 Manas Bhardwaj 4,539
4 Maciej Los 3,845


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100