<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>celsobarriga-dot-com &#187; Cpp</title>
	<atom:link href="http://www.celsobarriga.com/category/cpp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.celsobarriga.com</link>
	<description>Wasting bandwidth in style!</description>
	<lastBuildDate>Fri, 06 Nov 2009 14:14:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Obtaining File Size</title>
		<link>http://www.celsobarriga.com/2004/10/29/obtaining-file-size/</link>
		<comments>http://www.celsobarriga.com/2004/10/29/obtaining-file-size/#comments</comments>
		<pubDate>Fri, 29 Oct 2004 19:32:57 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Cpp]]></category>
		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://home.barriga.net/?p=7</guid>
		<description><![CDATA[The following snippet will determine the file size.

#include &#60;iostream.h&#62;
#include &#60;fstream.h&#62;

const char* filename = "example.txt";

int main() {
    long l, m;

    ifstream file(filename, ios::in&#124;ios::binary);
    l = file.tellg();
    file.seekg(0, ios::end);
    m = file.tellg();
    file.close();

    cout &#60;&#60; "size [...]]]></description>
			<content:encoded><![CDATA[<p>The following snippet will determine the file size.</p>
<blockquote><pre><code>
#include &lt;iostream.h&gt;
#include &lt;fstream.h&gt;

const char* filename = "example.txt";

int main() {
    long l, m;

    ifstream file(filename, ios::in|ios::binary);
    l = file.tellg();
    file.seekg(0, ios::end);
    m = file.tellg();
    file.close();

    cout &lt;&lt; "size of " &lt;&lt; filename;
    cout &lt;&lt; " is " &gt;&gt; (m-1) &lt;&lt; " bytes.\n";

    return 0;
}
</code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2004/10/29/obtaining-file-size/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Write To A Text File</title>
		<link>http://www.celsobarriga.com/2004/10/29/write-to-a-text-file/</link>
		<comments>http://www.celsobarriga.com/2004/10/29/write-to-a-text-file/#comments</comments>
		<pubDate>Fri, 29 Oct 2004 19:18:02 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Cpp]]></category>
		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://home.barriga.net/?p=6</guid>
		<description><![CDATA[This snippet will write a text file.

#include &#60;fstream.h&#62;

int main() {
    ofstream outfile("example.txt");
    if (outfile.is_open()) {
        outfile &#60;&#60; "This is a line.\n";
        outfile &#60;&#60; "This is another line.\n";
        outfile.close();
 [...]]]></description>
			<content:encoded><![CDATA[<p>This snippet will write a text file.</p>
<blockquote><pre><code>
#include &lt;fstream.h&gt;

int main() {
    ofstream outfile("example.txt");
    if (outfile.is_open()) {
        outfile &lt;&lt; "This is a line.\n";
        outfile &lt;&lt; "This is another line.\n";
        outfile.close();
    }
    return 0;
}
</code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2004/10/29/write-to-a-text-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Read A Text File</title>
		<link>http://www.celsobarriga.com/2004/07/21/read-a-text-file/</link>
		<comments>http://www.celsobarriga.com/2004/07/21/read-a-text-file/#comments</comments>
		<pubDate>Wed, 21 Jul 2004 19:16:24 +0000</pubDate>
		<dc:creator>celso</dc:creator>
				<category><![CDATA[Cpp]]></category>
		<category><![CDATA[Notes]]></category>

		<guid isPermaLink="false">http://home.barriga.net/?p=5</guid>
		<description><![CDATA[This will open a text file and read it line by line. As it is, it will just print each line to the screen, so very much like the unix &#8216;cat&#8217; command, but could very well do anything on the line just read by replacing the cout statement.

#include &#60;fstream&#62;
#include &#60;iostream&#62;
#include &#60;string&#62;

void main() {
   [...]]]></description>
			<content:encoded><![CDATA[<p>This will open a text file and read it line by line. As it is, it will just print each line to the screen, so very much like the unix &#8216;cat&#8217; command, but could very well do anything on the line just read by replacing the cout statement.</p>
<blockquote><pre><code>
#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

void main() {
    string s;
    ifstream infile;

    infile.open("aaa.txt");

    while(infile &gt;&gt; s) {
        cout &lt;&lt; s &lt;&lt; endl;
    }
}
</code></pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.celsobarriga.com/2004/07/21/read-a-text-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
