summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-10-09 20:44:57 +0100
committerPatrick Simianer <p@simianer.de>2014-10-09 20:44:57 +0100
commitde54ca7c31487a33fa8148159e9b3dea96a9dd4c (patch)
tree80262d62d51c64af4fc01490f81b1dad06b56c42
parente14fc9af4e74a2ed05361224fd13ed4cc61479ec (diff)
cast char
-rw-r--r--c,cc/cast_char.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/c,cc/cast_char.cc b/c,cc/cast_char.cc
new file mode 100644
index 0000000..c3a3315
--- /dev/null
+++ b/c,cc/cast_char.cc
@@ -0,0 +1,21 @@
+#include <iostream>
+
+using namespace std;
+
+int main(void)
+{
+ int i = 255;
+ char c = 'x';
+ char d = -1;
+ char e = 255;
+ char f = 'f';
+ char q = 127;
+
+ std::cout << (char)i << std::endl;
+ std::cout << (int)c << std::endl;
+ std::cout << (int)d << std::endl;
+ std::cout << (int)e << std::endl;
+ std::cout << (int)f << std::endl;
+ std::cout << (int)q << std::endl;
+}
+