Changeset 091011a
- Timestamp:
- Apr 28, 2021, 10:04:07 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- c132d50
- Parents:
- 99b2407
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/strstream.cfa
r99b2407 r091011a 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 1 13 #include <fstream.hfa> 2 14 #include <strstream.hfa> 3 15 4 16 int main() { 5 6 char buf[size]; 7 ostrstream osstr = { buf, size }; 8 9 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; 10 22 11 osstr | i | hex(j) | wd(10, k) | sci(x) | unit(eng(y)); 12 13 14 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)); 15 27 16 // char buf2[] = "12 14 15 3.5 7e4"; 17 18 19 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; 20 32 } 33 34 // Local Variables: // 35 // tab-width: 4 // 36 // compile-command: "cfa strstream.cfa" // 37 // End: //
Note: See TracChangeset
for help on using the changeset viewer.