source: src/tests/io.c@ 8b52686

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 8b52686 was 7ff30d07, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Conflicts:

Makefile.in
aclocal.m4
configure
src/Makefile.in
src/Tests/Context.c
src/driver/Makefile.in
src/examples/Makefile.in
src/examples/ctxts.c
src/examples/esskaykay.c
src/libcfa/Makefile.in

  • Property mode set to 100644
File size: 2.8 KB
Line 
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
13// Last Modified On : Wed Jun 8 22:52:04 2016
14// Update Count : 30
15//
16
17#include <fstream>
18
19int 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 int x = 3, y = 5, z = 7;
38 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;
39 sout | 1 | 2 | 3 | endl;
40 sout | '1' | '2' | '3' | endl;
41 sout | 1 | "" | 2 | "" | 3 | endl;
42 sout | endl;
43
44 ifstream in; // create / open file
45 open( &in, "io.data", "r" );
46
47 &in | &c // character
48 | &si | &usi | &i | &ui | &li | &uli | &lli | &ulli // integral
49 | &f | &d | &ld // floating point
50 | &fc | &dc | &ldc // floating-point complex
51 | cstr( s1 ) | cstr( s2, 10 ); // C string, length unchecked and checked
52
53 sout | c | ' ' | endl // character
54 | si | usi | i | ui | li | uli | lli | ulli | endl // integral
55 | f | d | ld | endl // floating point
56 | fc | dc | ldc | endl; // complex
57 sout | endl;
58 sout | f | "" | d | "" | ld | endl // floating point without separator
59 | sepDisable | fc | dc | ldc | sepEnable | endl // complex without separator
60 | sepOn | s1 | sepOff | s2 | endl // local separator removal
61 | s1 | "" | s2 | endl; // C string without separator
62 sout | endl;
63
64 sepSet( sout, ", $" ); // change separator, maximum of 15 characters
65 sout | f | d | ld | endl // floating point without separator
66 | fc | dc | ldc | endl // complex without separator
67 | s1 | s2 | endl;
68 sout | endl;
69 sepSet( sout, " " );
70
71 sout
72 // opening delimiters
73 | "v(" | 27
74 | "v[" | 27
75 | "v{" | 27
76 | "$" | 27
77 | "£" | 27
78 | "¥" | 27
79 | "¡" | 27
80 | "¿" | 27
81 | "«" | 27
82 | endl
83 // closing delimiters
84 | 25 | ","
85 | 25 | "."
86 | 25 | ":"
87 | 25 | ";"
88 | 25 | "!"
89 | 25 | "?"
90 | 25 | ")"
91 | 25 | "]"
92 | 25 | "}"
93 | 25 | "%"
94 | 25 | "¢"
95 | 25 | "»"
96 | endl
97 // opening-closing delimiters
98 | 25 | "'" | 27
99 | 25 | "`" | 27
100 | 25 | "\"" | 27
101 | 25 | " " | 27
102 | 25 | "\f" | 27
103 | 25 | "\n" | 27
104 | 25 | "\r" | 27
105 | 25 | "\t" | 27
106 | 25 | "\v" | 27
107 | endl;
108}
109
110// Local Variables: //
111// tab-width: 4 //
112// compile-command: "cfa io.c" //
113// End: //
Note: See TracBrowser for help on using the repository browser.