source: src/tests/io.c @ a62cbb3

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since a62cbb3 was a6151ba, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

update comments in code and tests, and add test searchsort

  • Property mode set to 100644
File size: 2.7 KB
Line 
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
12// Last Modified On : Tue Jul  5 18:29:23 2016
13// Update Count     : 31
14//
15
16#include <fstream>
17
18int 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
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
43        ifstream in;                                                                                            // create / open file
44        open( &in, "io.data", "r" );
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
60                 | s1 | "" | s2 | endl;                                                                 // C string without separator
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;
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
78                | "¡" | 27
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
100                | 25 | " " | 27
101                | 25 | "\f" | 27
102                | 25 | "\n" | 27
103                | 25 | "\r" | 27
104                | 25 | "\t" | 27
105                | 25 | "\v" | 27
106                | endl;
107}
108
109// Local Variables: //
110// tab-width: 4 //
111// compile-command: "cfa io.c" //
112// End: //
Note: See TracBrowser for help on using the repository browser.