<?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>Comparison of programming languages &#8211; Henry Poon&#039;s Blog</title>
	<atom:link href="https://blog.henrypoon.com/blog/tag/comparison-of-programming-languages/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.henrypoon.com</link>
	<description></description>
	<lastBuildDate>Tue, 04 Oct 2022 22:02:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
<site xmlns="com-wordpress:feed-additions:1">83044199</site>	<item>
		<title>C++ Trimming Leading or Trailing Spaces</title>
		<link>https://blog.henrypoon.com/blog/2010/02/28/c-trimming-leading-or-trailing-spaces/</link>
					<comments>https://blog.henrypoon.com/blog/2010/02/28/c-trimming-leading-or-trailing-spaces/#respond</comments>
		
		<dc:creator><![CDATA[hp]]></dc:creator>
		<pubDate>Mon, 01 Mar 2010 01:18:02 +0000</pubDate>
				<category><![CDATA[computer stuff]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Comparison of programming languages]]></category>
		<category><![CDATA[D]]></category>
		<category><![CDATA[Find]]></category>
		<category><![CDATA[It]]></category>
		<category><![CDATA[Module:Sandbox/Gadget850/Echo]]></category>
		<category><![CDATA[STR]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[Thou]]></category>
		<guid isPermaLink="false">http://henrypoon.mooo.com/blog/c-trimming-leading-or-trailing-spaces</guid>

					<description><![CDATA[One can use one of the string methods find_last_not_of and find_first_not_of. What these methods do is that they return the index of the string where the character in that index does NOT match what you are looking for. For example: To get rid of the leading and trailing spaces in that string, we can do [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">One can use one of the string methods <em>find_last_not_of </em>and <em>find_first_not_of. </em>What these methods do is that they return the index of the string where the character in that index does NOT match what you are looking for.</p>



<p class="wp-block-paragraph">For example:</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">string str = " TEST STRING "; //there is a space in the beginning and end
cout &lt;&lt; str.find_first_not_of(" ") &lt;&lt; endl; //this line will return a 1, because thats the first thats not of a " </code></pre>



<p class="wp-block-paragraph">To get rid of the leading and trailing spaces in that string, we can do this:</p>



<pre class="wp-block-code"><code lang="cpp" class="language-cpp">str = str.substr(str.find_first_not_of(" ")); //str will now be assigned "TEST STRING ", note that there is still a space at the end

str = str.substr(0, str.find_last_not_of(" ") + 1) //now the trailing space is removed. &amp;amp;nbsp;a 1 is added because without it, we would get "TEST STRIN" instead.  the 1 ensures that only the space is removed</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.henrypoon.com/blog/2010/02/28/c-trimming-leading-or-trailing-spaces/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">262</post-id>	</item>
	</channel>
</rss>
