473,385 Members | 1,630 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,385 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 2422
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
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.