473,320 Members | 2,107 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,320 software developers and data experts.

number of bytes for a type in C++

In C++, the amount of memory used to store int is 4 bytes, or dependent
upon the hardware?
I think still dependent on the machine, since C++ compiler is platform
dependent.

Please advise. Thanks

Jul 22 '05 #1
6 2419
I believe that the standard guarantees minimum ranges for intrinsic
types. For example, I believe that the minimum range for type int is
[-32768, +32767].

Regards,

Jon Trauntvein

Jul 22 '05 #2
jr********@hotmail.com wrote:
In C++, the amount of memory used to store int is 4 bytes, or dependent
upon the hardware?
I think still dependent on the machine, since C++ compiler is platform
dependent.


You think right.
Jul 22 '05 #3
It is depending upon the hardware.

According to TCPPPL,
this is what guaranteed about the sizes of fundamental types

1 = sizeof(char) <= sizeof(short) <= sizeof(int) <=sizeof(long)
1<= sizeof(bool) <= sizeof(long)
sizeof(char) <=sizeof(wchar_t) <= sizeof(long)
sizeof(float) <= sizeof(double) <= sizeof(long double)
sizeof(N) = sizeof(signed N) = sizeof(unsigned N)

Jul 22 '05 #4
On 10 Dec 2004 09:07:28 -0800, in comp.lang.c , pv**********@gmail.com
wrote:
It is depending upon the hardware.


And the compiler. Think about old DOS compilers.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 22 '05 #5
jr********@hotmail.com writes:
In C++, the amount of memory used to store int is 4 bytes, or dependent
upon the hardware?
I think still dependent on the machine, since C++ compiler is platform
dependent.


In C, it's dependent on the implementation, with some specific
constraints imposed by the standard.

But since your question is about C++, cross-posting it to comp.lang.c
was a bad idea.

Followups redirected.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jul 22 '05 #6
Keith Thompson wrote:
jr********@hotmail.com writes:
In C++, the amount of memory used to store int is 4 bytes, or dependent
upon the hardware?
I think still dependent on the machine, since C++ compiler is platform
dependent.


In C, it's dependent on the implementation, with some specific
constraints imposed by the standard.


The same is true for C++. The rules regarding integer type sizes are the
same in C++ as in C, with the exception that C++ doesn't know the "long
long" type.

Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Gavin | last post by:
Hi, I'm a newbie to programming of any kind. I have posted this to other groups in a hope to get a response from anyone. Can any one tell me how to make my VB program read the Bios serial number...
5
by: Sam Smith | last post by:
Hi, is there a function or a "well-known" algorithm which converts a number of random length represented as an array of bytes to its binary format? For example: a 16 byte long array:...
6
by: Herrcho | last post by:
in K&R Chapter 6.3 it mentions two methods to calculate NKEYS. and points out the first one which is to terminate the list of initializers with a null pointer, then loop along keytab until the...
122
by: Einar | last post by:
Hi, I wonder if there is a nice bit twiddling hack to compare a large number of variables? If you first store them in an array, you can do: for (i = 0; i < n; i++) { if (array != value) {...
12
by: george r smith | last post by:
Greetings, What is the C# code that returns the number of bytes in a string such as 32313131353131333432317E547E3132357E5553447E467E3536363031303030343835323632 7E307E56 It should be 80 I...
1
by: William Connery | last post by:
Hi, I have a small python program with e-mail capabilities that I have pieced together from code snippets found on the internet. The program uses the smtplib module to successfully send an...
19
by: VK | last post by:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/ b495b4898808fde0> is more than one month old - this may pose problem for posting over some news servers. This is why I'm...
4
by: sumedh..... | last post by:
In a compiler there are 36bits for a word and to store a character 8bits are needed. In this to store a character two words appended. Then for storing k characters string,how many words are needed?
25
by: Daniel Kraft | last post by:
Hi, I do need to implement something similar to C++'s std::bitset in C; for this, I use an array of int's to get together any desired number of bits, possibly larger than 32/64 or anything like...
58
by: sh.vipin | last post by:
is there any way to find out number of bytes freed on a particular free() call in C
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.