A
arnuld
this programme runs without any trouble. it took 45 minutes of typing.
i posted it here so that people can save their precious time:
// Stroustrup special edition
// chapter 4 exercise 2
// printing the sizes of different types
#include <iostream>
int main() {
bool b;
char c;
signed char sc;
unsigned char uc;
wchar_t wc;
int i;
unsigned int ui;
short s;
unsigned short us;
long l;
unsigned long ul;
float f;
double d;
long double ld;
bool* bp;
char* cp;
signed char* scp;
unsigned char* ucp;
int* ip;
unsigned int* uip;
short* sp;
unsigned short* usp;
long* lp;
unsigned long* ulp;
float* fp;
double* dp;
long double* ldp;
std::cout << "bool: \t" << sizeof(b)
<< "\n"
<< "char: \t" << sizeof(c) << "\n"
<< "signed char: \t" << sizeof(sc) << "\n"
<< "unsigned char: \t" << sizeof(uc) << "\n"
<< "wchar_t: \t" << sizeof(wc) << "\n"
<< "int: \t" << sizeof(i) << "\n"
<< "unsigned int: \t" << sizeof(ui) << "\n"
<< "short: \t" << sizeof(s) << "\n"
<< "unsigned short: \t" << sizeof(us) << "\n"
<< "long: \t" << sizeof(l) << "\n"
<< "unsigned long: \t" << sizeof(ul) << "\n"
<< "float: \t" << sizeof(f) << "\n"
<< "double: \t" << sizeof(d) << "\n"
<< "long double: \t" << sizeof(ld) << "\n"
<< "bool*: \t" << sizeof(bp) <<
"\n"
<< "char*: \t" << sizeof(cp) <<
"\n"
<< "unsigned char*: \t" << sizeof(ucp) <<
"\n"
<< "int*: \t" << sizeof(ip) << "\n"
<< "signed char*: \t" << sizeof(scp) << "\n"
<< "unsigned int*: \t" << sizeof(uip) << "\n"
<< "short*: \t" << sizeof(sp) << "\n"
<< "unsigned short*: \t" << sizeof(usp) << "\n"
<< "long*: \t" << sizeof(lp) << "\n"
<< "unsigned long*: \t" << sizeof(ulp) << "\n"
<< "float*: \t" << sizeof(fp) << "\n"
<< "double* \t" << sizeof(dp) << "\n"
<< "long double*: \t " << sizeof(ldp) << "\n"
<< "\n";
}
// created with Emacs, the true text editor
i posted it here so that people can save their precious time:
// Stroustrup special edition
// chapter 4 exercise 2
// printing the sizes of different types
#include <iostream>
int main() {
bool b;
char c;
signed char sc;
unsigned char uc;
wchar_t wc;
int i;
unsigned int ui;
short s;
unsigned short us;
long l;
unsigned long ul;
float f;
double d;
long double ld;
bool* bp;
char* cp;
signed char* scp;
unsigned char* ucp;
int* ip;
unsigned int* uip;
short* sp;
unsigned short* usp;
long* lp;
unsigned long* ulp;
float* fp;
double* dp;
long double* ldp;
std::cout << "bool: \t" << sizeof(b)
<< "\n"
<< "char: \t" << sizeof(c) << "\n"
<< "signed char: \t" << sizeof(sc) << "\n"
<< "unsigned char: \t" << sizeof(uc) << "\n"
<< "wchar_t: \t" << sizeof(wc) << "\n"
<< "int: \t" << sizeof(i) << "\n"
<< "unsigned int: \t" << sizeof(ui) << "\n"
<< "short: \t" << sizeof(s) << "\n"
<< "unsigned short: \t" << sizeof(us) << "\n"
<< "long: \t" << sizeof(l) << "\n"
<< "unsigned long: \t" << sizeof(ul) << "\n"
<< "float: \t" << sizeof(f) << "\n"
<< "double: \t" << sizeof(d) << "\n"
<< "long double: \t" << sizeof(ld) << "\n"
<< "bool*: \t" << sizeof(bp) <<
"\n"
<< "char*: \t" << sizeof(cp) <<
"\n"
<< "unsigned char*: \t" << sizeof(ucp) <<
"\n"
<< "int*: \t" << sizeof(ip) << "\n"
<< "signed char*: \t" << sizeof(scp) << "\n"
<< "unsigned int*: \t" << sizeof(uip) << "\n"
<< "short*: \t" << sizeof(sp) << "\n"
<< "unsigned short*: \t" << sizeof(usp) << "\n"
<< "long*: \t" << sizeof(lp) << "\n"
<< "unsigned long*: \t" << sizeof(ulp) << "\n"
<< "float*: \t" << sizeof(fp) << "\n"
<< "double* \t" << sizeof(dp) << "\n"
<< "long double*: \t " << sizeof(ldp) << "\n"
<< "\n";
}
// created with Emacs, the true text editor