[53ba273] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
| 7 | // io.c -- |
---|
| 8 | // |
---|
| 9 | // Author : Peter A. Buhr |
---|
| 10 | // Created On : Wed Mar 2 16:56:02 2016 |
---|
| 11 | // Last Modified By : Peter A. Buhr |
---|
[a6151ba] | 12 | // Last Modified On : Tue Jul 5 18:29:23 2016 |
---|
| 13 | // Update Count : 31 |
---|
[53ba273] | 14 | // |
---|
| 15 | |
---|
| 16 | #include <fstream> |
---|
| 17 | |
---|
| 18 | int main() { |
---|
| 19 | char c; // basic types |
---|
| 20 | short int si; |
---|
| 21 | unsigned short int usi; |
---|
| 22 | int i; |
---|
| 23 | unsigned int ui; |
---|
| 24 | long int li; |
---|
| 25 | unsigned long int uli; |
---|
| 26 | long long int lli; |
---|
| 27 | unsigned long long int ulli; |
---|
| 28 | float f; |
---|
| 29 | double d; |
---|
| 30 | long double ld; |
---|
| 31 | float _Complex fc; |
---|
| 32 | double _Complex dc; |
---|
| 33 | long double _Complex ldc; |
---|
| 34 | char s1[10], s2[10]; |
---|
| 35 | |
---|
[58b5d03] | 36 | int x = 3, y = 5, z = 7; |
---|
| 37 | sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl; |
---|
| 38 | sout | 1 | 2 | 3 | endl; |
---|
| 39 | sout | '1' | '2' | '3' | endl; |
---|
| 40 | sout | 1 | "" | 2 | "" | 3 | endl; |
---|
| 41 | sout | endl; |
---|
| 42 | |
---|
[53ba273] | 43 | ifstream in; // create / open file |
---|
[6b6597c] | 44 | open( &in, "io.data", "r" ); |
---|
[53ba273] | 45 | |
---|
| 46 | &in | &c // character |
---|
| 47 | | &si | &usi | &i | &ui | &li | &uli | &lli | &ulli // integral |
---|
| 48 | | &f | &d | &ld // floating point |
---|
| 49 | | &fc | &dc | &ldc // floating-point complex |
---|
| 50 | | cstr( s1 ) | cstr( s2, 10 ); // C string, length unchecked and checked |
---|
| 51 | |
---|
| 52 | sout | c | ' ' | endl // character |
---|
| 53 | | si | usi | i | ui | li | uli | lli | ulli | endl // integral |
---|
| 54 | | f | d | ld | endl // floating point |
---|
| 55 | | fc | dc | ldc | endl; // complex |
---|
| 56 | sout | endl; |
---|
| 57 | sout | f | "" | d | "" | ld | endl // floating point without separator |
---|
| 58 | | sepDisable | fc | dc | ldc | sepEnable | endl // complex without separator |
---|
| 59 | | sepOn | s1 | sepOff | s2 | endl // local separator removal |
---|
[b72bad4f] | 60 | | s1 | "" | s2 | endl; // C string without separator |
---|
[53ba273] | 61 | sout | endl; |
---|
| 62 | |
---|
| 63 | sepSet( sout, ", $" ); // change separator, maximum of 15 characters |
---|
| 64 | sout | f | d | ld | endl // floating point without separator |
---|
| 65 | | fc | dc | ldc | endl // complex without separator |
---|
| 66 | | s1 | s2 | endl; |
---|
[6b6597c] | 67 | sout | endl; |
---|
| 68 | sepSet( sout, " " ); |
---|
| 69 | |
---|
| 70 | sout |
---|
| 71 | // opening delimiters |
---|
| 72 | | "v(" | 27 |
---|
| 73 | | "v[" | 27 |
---|
| 74 | | "v{" | 27 |
---|
| 75 | | "$" | 27 |
---|
| 76 | | "£" | 27 |
---|
| 77 | | "¥" | 27 |
---|
[e945826] | 78 | | "¡" | 27 |
---|
[6b6597c] | 79 | | "¿" | 27 |
---|
| 80 | | "«" | 27 |
---|
| 81 | | endl |
---|
| 82 | // closing delimiters |
---|
| 83 | | 25 | "," |
---|
| 84 | | 25 | "." |
---|
| 85 | | 25 | ":" |
---|
| 86 | | 25 | ";" |
---|
| 87 | | 25 | "!" |
---|
| 88 | | 25 | "?" |
---|
| 89 | | 25 | ")" |
---|
| 90 | | 25 | "]" |
---|
| 91 | | 25 | "}" |
---|
| 92 | | 25 | "%" |
---|
| 93 | | 25 | "¢" |
---|
| 94 | | 25 | "»" |
---|
| 95 | | endl |
---|
| 96 | // opening-closing delimiters |
---|
| 97 | | 25 | "'" | 27 |
---|
| 98 | | 25 | "`" | 27 |
---|
| 99 | | 25 | "\"" | 27 |
---|
[dd51906] | 100 | | 25 | " " | 27 |
---|
[6b6597c] | 101 | | 25 | "\f" | 27 |
---|
| 102 | | 25 | "\n" | 27 |
---|
| 103 | | 25 | "\r" | 27 |
---|
| 104 | | 25 | "\t" | 27 |
---|
| 105 | | 25 | "\v" | 27 |
---|
| 106 | | endl; |
---|
[53ba273] | 107 | } |
---|
| 108 | |
---|
| 109 | // Local Variables: // |
---|
| 110 | // tab-width: 4 // |
---|
| 111 | // compile-command: "cfa io.c" // |
---|
| 112 | // End: // |
---|