<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: 6.6 &#8212; C-style strings</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/66-c-style-strings/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/66-c-style-strings/</link>
	<description></description>
	<lastBuildDate>Thu, 02 Feb 2012 21:20:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: zingmars</title>
		<link>http://www.learncpp.com/cpp-tutorial/66-c-style-strings/comment-page-1/#comment-96116</link>
		<dc:creator>zingmars</dc:creator>
		<pubDate>Sat, 08 Oct 2011 12:55:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/66-c-style-strings/#comment-96116</guid>
		<description>It&#039;s legal, but confusing at first and you might need to overload operators if you want to print the strings.</description>
		<content:encoded><![CDATA[<p>It&#8217;s legal, but confusing at first and you might need to overload operators if you want to print the strings.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Iodream</title>
		<link>http://www.learncpp.com/cpp-tutorial/66-c-style-strings/comment-page-1/#comment-95916</link>
		<dc:creator>Iodream</dc:creator>
		<pubDate>Mon, 22 Aug 2011 11:43:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/66-c-style-strings/#comment-95916</guid>
		<description>Well, i initialize an array of 3 strings. 
Then the first loop goes through the indexes of the array and 
the 2nd loop through each character of the currently selected by the first loop string. 
Yes, i made a mistake when i initialize the array there should be a different name &quot;szStringArrayAdd[3]&quot;
Im just trying to write a program and im getting errors (errors directly in Visual Studio&#039;s code window)

I am asking if what ive written above is legal.</description>
		<content:encoded><![CDATA[<p>Well, i initialize an array of 3 strings.<br />
Then the first loop goes through the indexes of the array and<br />
the 2nd loop through each character of the currently selected by the first loop string.<br />
Yes, i made a mistake when i initialize the array there should be a different name &#8220;szStringArrayAdd[3]&#8221;<br />
Im just trying to write a program and im getting errors (errors directly in Visual Studio&#8217;s code window)</p>
<p>I am asking if what ive written above is legal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Iodream</title>
		<link>http://www.learncpp.com/cpp-tutorial/66-c-style-strings/comment-page-1/#comment-95915</link>
		<dc:creator>Iodream</dc:creator>
		<pubDate>Mon, 22 Aug 2011 11:42:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/66-c-style-strings/#comment-95915</guid>
		<description>Well, i initialize an array of 3 strings. 
Then the first loop goes through the indexes of the array and 
the 2nd loop through each character of the currently selected by the first loop string. 
Yes, i made a mistake when i initialize the array there should be a different name &quot;szStringArrayAdd[3]&quot;
Im just trying to write a program and im getting errors (errors directly in Visual Studio&#039;s code window)
I am asking if what ive written above is legal.</description>
		<content:encoded><![CDATA[<p>Well, i initialize an array of 3 strings.<br />
Then the first loop goes through the indexes of the array and<br />
the 2nd loop through each character of the currently selected by the first loop string.<br />
Yes, i made a mistake when i initialize the array there should be a different name &#8220;szStringArrayAdd[3]&#8221;<br />
Im just trying to write a program and im getting errors (errors directly in Visual Studio&#8217;s code window)<br />
I am asking if what ive written above is legal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zingmars</title>
		<link>http://www.learncpp.com/cpp-tutorial/66-c-style-strings/comment-page-1/#comment-95903</link>
		<dc:creator>zingmars</dc:creator>
		<pubDate>Sat, 20 Aug 2011 15:57:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/66-c-style-strings/#comment-95903</guid>
		<description>I&#039;m not sure what you tried to do there, but the code looks really wrong. 
wouldn&#039;t a single for loop suffice?</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure what you tried to do there, but the code looks really wrong.<br />
wouldn&#8217;t a single for loop suffice?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Iodream</title>
		<link>http://www.learncpp.com/cpp-tutorial/66-c-style-strings/comment-page-1/#comment-95815</link>
		<dc:creator>Iodream</dc:creator>
		<pubDate>Wed, 03 Aug 2011 17:07:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/66-c-style-strings/#comment-95815</guid>
		<description>Hello. What if i want to access each symbol of a string array?
Would it look something like this: 

&lt;PRE&gt;

string  szStringArray[3];

for (int iii=0;iii&lt;3;iii++)
 for (int jjj=0;jjj&lt;szStringArrayAdd[iii].length();jjj++)
   szStringArrayAdd[jjj][iii]= // do something. 

&lt;/PRE&gt;
 ?</description>
		<content:encoded><![CDATA[<p>Hello. What if i want to access each symbol of a string array?<br />
Would it look something like this: </p>
<pre>

string  szStringArray[3];

for (int iii=0;iii&lt;3;iii++)
 for (int jjj=0;jjj&lt;szStringArrayAdd[iii].length();jjj++)
   szStringArrayAdd[jjj][iii]= // do something. 
</pre>
<p> ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: newUser</title>
		<link>http://www.learncpp.com/cpp-tutorial/66-c-style-strings/comment-page-1/#comment-95335</link>
		<dc:creator>newUser</dc:creator>
		<pubDate>Sat, 16 Apr 2011 01:20:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/66-c-style-strings/#comment-95335</guid>
		<description>I&#039;ve made some minor adjustions, namely how I did namespaces (used the suggestion from the section) and I corrected the function parameter constant.

&lt;code&gt;/* Section: header */
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;cstdlib&gt;
#include &lt;string&gt;

/* Section: constant */
const std::string NEWLINE = &quot;\n&quot;

/* Section: prototype */
void nfound( const std::string &amp;v_file );

int main( int argc, char *argv[] ) {
  using namespace std;
  string the_file = &quot;test_file.txt&quot;;
  if ( &quot;the_file&quot; ) {
    cout &lt;&lt; &quot;File found!&quot;;
  } else {
    cout &lt;&lt; &quot;File not found!&quot;;
    nfound( &quot;the_file&quot; );
  }

  cin.get();
}

void nfound( const std::string &amp;v_file ) {
  using namespace std;
  ofstream a_file ( &quot;v_file&quot; );
  a_file &lt;&lt; &quot;This text will go inside!NEWLINE&quot;;
  a_file.close();
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I&#8217;ve made some minor adjustions, namely how I did namespaces (used the suggestion from the section) and I corrected the function parameter constant.</p>
<p><code>/* Section: header */<br />
#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;string&gt;</p>
<p>/* Section: constant */<br />
const std::string NEWLINE = &quot;\n&quot;</p>
<p>/* Section: prototype */<br />
void nfound( const std::string &amp;v_file );</p>
<p>int main( int argc, char *argv[] ) {<br />
  using namespace std;<br />
  string the_file = &quot;test_file.txt&quot;;<br />
  if ( &quot;the_file&quot; ) {<br />
    cout &lt;&lt; &quot;File found!&quot;;<br />
  } else {<br />
    cout &lt;&lt; &quot;File not found!&quot;;<br />
    nfound( &quot;the_file&quot; );<br />
  }</p>
<p>  cin.get();<br />
}</p>
<p>void nfound( const std::string &amp;v_file ) {<br />
  using namespace std;<br />
  ofstream a_file ( &quot;v_file&quot; );<br />
  a_file &lt;&lt; &quot;This text will go inside!NEWLINE&quot;;<br />
  a_file.close();<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: newUser</title>
		<link>http://www.learncpp.com/cpp-tutorial/66-c-style-strings/comment-page-1/#comment-95321</link>
		<dc:creator>newUser</dc:creator>
		<pubDate>Wed, 13 Apr 2011 02:36:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/66-c-style-strings/#comment-95321</guid>
		<description>&lt;code&gt;/* Section: header */
#include &lt;iostream&gt;
#include &lt;fstream&gt;
#include &lt;cstdlib&gt;
#include &lt;string&gt;

/* Section: namespace */
using namespace std;

/* Section: constant */
const string NEWLINE = &quot;\n&quot; // similar to: #define NEWLINE &#039;\n&#039;

/* Section: prototype */
void nfound( const string &amp;&quot;v_file&quot; );

int main( int argc, char *argv[] ) {
  string the_file = &quot;test_file.txt&quot;;
  if ( &quot;the_file&quot; ) {
    cout &lt;&lt; &quot;File found!&quot;;
  } else {
    cout &lt;&lt; &quot;File not found!&quot;;
    nfound( &quot;the_file&quot; );
  }

  cin.get();
}

void nfound( const string &amp;&quot;v_file&quot; ) {
  ofstream a_file ( &quot;v_file&quot; );
  a_file &lt;&lt; &quot;This text will go inside!NEWLINE&quot;;
  a_file.close();
}
&lt;/code&gt;

This is my simple program that I want to check if a file exists, if not make it with some writting in it. The problem is I get these errors:
&lt;cite&gt;
14: error: expected &#039;,&#039; or &#039;;&#039; before &#039;void&#039;
In function &#039;int main(int, char**)&#039;:
22: error: &#039;nfound&#039; was not declared in this scope
At global scope:
28: error: expected &#039;,&#039; or &#039;...&#039; before string constant
&lt;/cite&gt;

I&#039;ve looked over the code and it seems right. None of the tutorials I&#039;ve read (best by far! really love the code section you have!) deal with a string as a parameter. Last tutorial didn&#039;t mention the string header (#include ), but including this still didn&#039;t help.</description>
		<content:encoded><![CDATA[<p><code>/* Section: header */<br />
#include &lt;iostream&gt;<br />
#include &lt;fstream&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;string&gt;</p>
<p>/* Section: namespace */<br />
using namespace std;</p>
<p>/* Section: constant */<br />
const string NEWLINE = &quot;\n&quot; // similar to: #define NEWLINE &#039;\n&#039;</p>
<p>/* Section: prototype */<br />
void nfound( const string &amp;&quot;v_file&quot; );</p>
<p>int main( int argc, char *argv[] ) {<br />
  string the_file = &quot;test_file.txt&quot;;<br />
  if ( &quot;the_file&quot; ) {<br />
    cout &lt;&lt; &quot;File found!&quot;;<br />
  } else {<br />
    cout &lt;&lt; &quot;File not found!&quot;;<br />
    nfound( &quot;the_file&quot; );<br />
  }</p>
<p>  cin.get();<br />
}</p>
<p>void nfound( const string &amp;&quot;v_file&quot; ) {<br />
  ofstream a_file ( &quot;v_file&quot; );<br />
  a_file &lt;&lt; &quot;This text will go inside!NEWLINE&quot;;<br />
  a_file.close();<br />
}<br />
</code></p>
<p>This is my simple program that I want to check if a file exists, if not make it with some writting in it. The problem is I get these errors:<br />
<cite><br />
14: error: expected &#8216;,&#8217; or &#8216;;&#8217; before &#8216;void&#8217;<br />
In function &#8216;int main(int, char**)&#8217;:<br />
22: error: &#8216;nfound&#8217; was not declared in this scope<br />
At global scope:<br />
28: error: expected &#8216;,&#8217; or &#8216;&#8230;&#8217; before string constant<br />
</cite></p>
<p>I&#8217;ve looked over the code and it seems right. None of the tutorials I&#8217;ve read (best by far! really love the code section you have!) deal with a string as a parameter. Last tutorial didn&#8217;t mention the string header (#include ), but including this still didn&#8217;t help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ogre</title>
		<link>http://www.learncpp.com/cpp-tutorial/66-c-style-strings/comment-page-1/#comment-95139</link>
		<dc:creator>Ogre</dc:creator>
		<pubDate>Thu, 27 Jan 2011 02:37:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/66-c-style-strings/#comment-95139</guid>
		<description>Ah, I just looked it up on another site, that is how it is. I just found that odd when I first saw it.</description>
		<content:encoded><![CDATA[<p>Ah, I just looked it up on another site, that is how it is. I just found that odd when I first saw it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ogre</title>
		<link>http://www.learncpp.com/cpp-tutorial/66-c-style-strings/comment-page-1/#comment-95138</link>
		<dc:creator>Ogre</dc:creator>
		<pubDate>Thu, 27 Jan 2011 02:32:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/66-c-style-strings/#comment-95138</guid>
		<description>When you first use cin.getline() you say that the parameter 255 means it will only read the first 254 characters, to leave space for the null terminator. But if you initialize the array with [255] then it will have room for 255 characters plus the null terminator, right?

Also, when you first use strncpy() you say that the parameter of 49 means that is the most amount of characters it will take (excluding the null terminator), but this is inconsistent with cin.getline(). Is this really how it is?

You may also want to make it clear that we need to include  for some functions.</description>
		<content:encoded><![CDATA[<p>When you first use cin.getline() you say that the parameter 255 means it will only read the first 254 characters, to leave space for the null terminator. But if you initialize the array with [255] then it will have room for 255 characters plus the null terminator, right?</p>
<p>Also, when you first use strncpy() you say that the parameter of 49 means that is the most amount of characters it will take (excluding the null terminator), but this is inconsistent with cin.getline(). Is this really how it is?</p>
<p>You may also want to make it clear that we need to include  for some functions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: subha</title>
		<link>http://www.learncpp.com/cpp-tutorial/66-c-style-strings/comment-page-1/#comment-93630</link>
		<dc:creator>subha</dc:creator>
		<pubDate>Wed, 13 Oct 2010 07:10:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/66-c-style-strings/#comment-93630</guid>
		<description>&lt;pre&gt; i want a source code for strrev(),strlwr(); &lt;/pre&gt;</description>
		<content:encoded><![CDATA[<pre> i want a source code for strrev(),strlwr(); </pre>
]]></content:encoded>
	</item>
</channel>
</rss>

