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