Try this out,
The book says 10 bytes the program below says 8 bytes
The other forum say this is a C++ software issue,[not the C++ IDE program] come on, come on 12 work OK but not the last one, Unless it is a raspberry pi 5 with 8 Gig of memory, and I find that hard to believe [But I would be open minded, if the claim was made]
#include <iostream>
using namespace std;
int main()
{
cout << "The size of bool is:\t" << sizeof(bool) << " bytes.\n"; //1
cout << "The size of char is:\t" << sizeof(char) << " bytes.\n"; //1
cout << "The size of short is:\t" << sizeof(short) << " bytes.\n"; //2
cout << "The size of int is:\t" << sizeof(int) << " bytes.\n"; //4
cout << "The size of float is:\t" << sizeof(float) << " bytes.\n"; //4
cout << "The size of long is:\t" << sizeof(long) << " bytes.\n"; //4
cout << "The size of double is:\t" << sizeof(double) << " bytes.\n"; //8
cout << "\n";
cout << "The size of unsigned short int is:\t" << sizeof(unsigned short int) << " bytes.\n"; //2
cout << "The size of unsigned long int is:\t" << sizeof(unsigned long int) << " bytes.\n"; //2
cout << "The size of long int is:\t\t" << sizeof(long int) << " bytes.\n"; //4
cout << "The size of wchar_t is:\t\t\t" << sizeof(wchar_t) << " bytes.\n"; //2
cout << "The size of unsigned int is:\t\t" << sizeof(unsigned int) << " bytes.\n"; //4
cout << "The size of long double is:\t\t" << sizeof(long double) << " bytes.\n"; //8 (should be 10 bytes)
return 0;
}
The book says 10 bytes the program below says 8 bytes
The other forum say this is a C++ software issue,[not the C++ IDE program] come on, come on 12 work OK but not the last one, Unless it is a raspberry pi 5 with 8 Gig of memory, and I find that hard to believe [But I would be open minded, if the claim was made]
#include <iostream>
using namespace std;
int main()
{
cout << "The size of bool is:\t" << sizeof(bool) << " bytes.\n"; //1
cout << "The size of char is:\t" << sizeof(char) << " bytes.\n"; //1
cout << "The size of short is:\t" << sizeof(short) << " bytes.\n"; //2
cout << "The size of int is:\t" << sizeof(int) << " bytes.\n"; //4
cout << "The size of float is:\t" << sizeof(float) << " bytes.\n"; //4
cout << "The size of long is:\t" << sizeof(long) << " bytes.\n"; //4
cout << "The size of double is:\t" << sizeof(double) << " bytes.\n"; //8
cout << "\n";
cout << "The size of unsigned short int is:\t" << sizeof(unsigned short int) << " bytes.\n"; //2
cout << "The size of unsigned long int is:\t" << sizeof(unsigned long int) << " bytes.\n"; //2
cout << "The size of long int is:\t\t" << sizeof(long int) << " bytes.\n"; //4
cout << "The size of wchar_t is:\t\t\t" << sizeof(wchar_t) << " bytes.\n"; //2
cout << "The size of unsigned int is:\t\t" << sizeof(unsigned int) << " bytes.\n"; //4
cout << "The size of long double is:\t\t" << sizeof(long double) << " bytes.\n"; //8 (should be 10 bytes)
return 0;
}
Statistics: Posted by ericAuckland — Sun Sep 08, 2024 5:17 pm — Replies 11 — Views 169