source: tests/strstream.cfa

Last change on this file was 091011a, checked in by Peter A. Buhr <pabuhr@…>, 3 years ago

formatting

  • Property mode set to 100644
File size: 987 bytes
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2021 University of Waterloo
3//
4// strstream.cfa --
5//
6// Author           : Peter A. Buhr
7// Created On       : Wed Apr 28 21:47:35 2021
8// Last Modified By : Peter A. Buhr
9// Last Modified On : Wed Apr 28 21:50:02 2021
10// Update Count     : 3
11//
12
13#include <fstream.hfa>
14#include <strstream.hfa>
15
16int main() {
17        enum { size = 256 };
18        char buf[size];                                                                         // output buffer
19        ostrstream osstr = { buf, size };                                       // bind output buffer/size
20        int i = 3, j = 5, k = 7;
21        double x = 12345678.9, y = 98765.4321e-11;
22
23        osstr | i | hex(j) | wd(10, k) | sci(x) | unit(eng(y)); // same lines of output
24        write( osstr );
25        printf( "%s", buf );
26        sout | i | hex(j) | wd(10, k) | sci(x) | unit(eng(y));
27
28        // char buf2[] = "12 14 15 3.5 7e4";                                    // input buffer
29        // istrstream isstr = { buf2 };
30        // isstr | i | j | k | x | y;
31        // sout | i | j | k | x | y;
32}
33
34// Local Variables: //
35// tab-width: 4 //
36// compile-command: "cfa strstream.cfa" //
37// End: //
Note: See TracBrowser for help on using the repository browser.