<?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>kwatog &#38; co.&#187; stl</title>
	<atom:link href="http://kwatog.com/tag/stl/feed/" rel="self" type="application/rss+xml" />
	<link>http://kwatog.com</link>
	<description>tech notes and general nonsense</description>
	<lastBuildDate>Tue, 31 Jan 2012 06:27:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Trim String in C++</title>
		<link>http://kwatog.com/blog/c/trim-string-in-c/</link>
		<comments>http://kwatog.com/blog/c/trim-string-in-c/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 07:59:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[standard template library]]></category>
		<category><![CDATA[stl]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[trim]]></category>
		<guid isPermaLink="false">http://kwatog.com/?p=165</guid>
		<description><![CDATA[Funny how a trivial task like trimming trailing spaces in C++ gets a bit harder if you insist on using STL (standard template library). But the good thing is, the internet is there and Google is so good at finding the right answer if you ask the right question. And after reading some samples, I [...]]]></description>
			<content:encoded><![CDATA[<p>Funny how a trivial task like trimming trailing spaces in C++ gets a bit harder if you insist on using STL (standard template library). But the good thing is, the internet is there and Google is so good at finding the right answer if you ask the right question. And after reading some samples, I found the solution.</p>
<p>Here&#8217;s the actual code that I used.<br />
<code>inline string trim_right (const string &#038; s)<br />
{<br />
    size_t found;<br />
    string whitespaces (" \t\n\r");</p>
<p>    string str (s);<br />
	found=str.find_last_not_of(whitespaces);<br />
	if (found!=string::npos){<br />
	   str.erase(found+1);<br />
	}<br />
	else{<br />
	   str.clear();<br />
	}<br />
	return str;<br />
}  </code></p>
<p>here&#8217;s a sample function call<br />
<code><br />
    string str1="lorem ipsum dolor        ";<br />
    string str2=" ";<br />
    str2=trim_right(str1);<br />
    cout << "->|" << str2.c_str() << "|<-";<br />
</code></p>
<p>Here's the shorter version of the code.<br />
<code><br />
   str=str.find_last_not_of(" \t\n\r");<br />
</code></p>
<p>Actually, there could be a ton of other implementation but that's what I'm using. If you know a better way, let me know.</p>
<h4>Incoming search terms:</h4><ul><li>trim c</li><li>c trim</li><li>trim string c</li><li>c trim string</li><li>trim string in c</li><li>trim in c string</li><li>trim string in c linux</li><li>trim strings in c</li><li>trimming in c string</li><li>TrimRight C</li></ul>]]></content:encoded>
			<wfw:commentRss>http://kwatog.com/blog/c/trim-string-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!--
Hyper cache file: 77acf343fd28c800b324dcefca09d9df
Cache created: 05-02-2012 02:28:50
HCE Version: 0.9.8
Load AVG: 0.01(5)
-->
