codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> using namespace std; template <typename T> int mysizeof(T) { T temp[2]; return (int)&temp[1] - (int)&temp[0]; } int main() { cout << "sizeof mysizeof" << endl; char c = 0; short s = 0; int i = 0; long l = 0; float f = 0; double d = 0; long double ld = 0; cout << "char: " << mysizeof(c) << endl; cout << "short: " << mysizeof(s) << endl; cout << "int: " << mysizeof(i) << endl; cout << "long: " << mysizeof(l) << endl; cout << "float: " << mysizeof(f) << endl; cout << "double: " << mysizeof(d) << endl; cout << "long double: " << mysizeof(ld) << endl; }
Private
[
?
]
Run code
Submit