akaros/tests/cpp_streams.cc
<<
>>
Prefs
   1#include <iostream>
   2#include <fstream>
   3#include <string>
   4#include <errno.h>
   5
   6#include <memory>
   7
   8using namespace std;
   9
  10struct foobar {
  11        int x;
  12};
  13
  14int main(void)
  15{
  16        string line;
  17        ifstream myfile;
  18        /* grep the asm for M_release to verify we're using atomics */
  19        std::shared_ptr<foobar> foo = make_shared<foobar>();
  20
  21        errno = 0;
  22        myfile.open("hello.txt", ifstream::in);
  23        if (errno)
  24                perror("Unable to open (hello.txt):");
  25        if (myfile.is_open()) {
  26                while (myfile.good()) {
  27                  getline(myfile, line);
  28                  cout << line << endl;
  29                }
  30                myfile.close();
  31                cout << "Stream test passed" << endl;
  32        } else {
  33                cout << "Unable to open file"; 
  34        }
  35        return 0;
  36}
  37