Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/strstream.cfa

    r091011a rc7015e6b  
    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 
    131#include <fstream.hfa>
    142#include <strstream.hfa>
    153
    164int 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;
     5    enum { size = 256 };
     6    char buf[size];
     7    ostrstream osstr = { buf, size };
     8    int i = 3, j = 5, k = 7;
     9    double x = 12345678.9, y = 98765.4321e-11;
    2210
    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));
     11    osstr | i | hex(j) | wd(10, k) | sci(x) | unit(eng(y));
     12    write( osstr );
     13    printf( "%s", buf );
     14    sout | i | hex(j) | wd(10, k) | sci(x) | unit(eng(y));
    2715
    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;
     16    // char buf2[] = "12 14 15 3.5 7e4";
     17    // istrstream isstr = { buf2 };
     18    // isstr | i | j | k | x | y;
     19    // sout | i | j | k | x | y;
    3220}
    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.