Overview
Features
Download
Documentation
Community
Add-Ons & Services

Reading/Writing text files on Windows

A general discussion forum.

Reading/Writing text files on Windows

Postby jshuler » 10 Jul 2009, 18:55

Are there any samples for reading and writing text files on Windows?
jshuler
 
Posts: 4
Joined: 10 Jul 2009, 18:53

Re: Reading/Writing text files on Windows

Postby bird » 12 Jul 2009, 02:29

Here's a bit of code that should help.

-Steve

Code: Select all

std::string file("testfile.txt");

   // write some text
   Poco::FileOutputStream fos(file, std::ios::binary);
   Poco::OutputLineEndingConverter out(fos, Poco::LineEnding::NEWLINE_CRLF);
   for( int i = 0; i < 10; i++ )
   {
      out << NumberFormatter::format(i) << "\n";
   }
   fos.close();

   // read some text
   Poco::FileInputStream fis(file);
   Poco::InputLineEndingConverter in(fis, Poco::LineEnding::NEWLINE_CRLF);
   std::string line;
   while( std::getline(in, line) )
   {
      std::cout << line << std::endl;
   }
   fis.close();
bird
 
Posts: 19
Joined: 22 Sep 2007, 16:57


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests