[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
|
---|
| 13 | // Last Modified On : Wed Apr 6 14:58:27 2016
|
---|
| 14 | // Update Count : 15
|
---|
| 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
|
---|
| 38 | open( &in, "input.data", "r" );
|
---|
| 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
|
---|
| 54 | | s1 | "" | s2 | endl; // C string withou separator
|
---|
| 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;
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | // Local Variables: //
|
---|
| 64 | // tab-width: 4 //
|
---|
| 65 | // compile-command: "cfa io.c" //
|
---|
| 66 | // End: //
|
---|