<?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: scanf in C : Reading single line of text using &quot;scanf&quot; function</title>
	<atom:link href="http://codereflect.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://codereflect.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/</link>
	<description>on programming tips and trending topics...</description>
	<lastBuildDate>Sun, 29 Jan 2012 09:15:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Ivan Vucica</title>
		<link>http://codereflect.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/comment-page-1/#comment-2877</link>
		<dc:creator>Ivan Vucica</dc:creator>
		<pubDate>Sat, 28 May 2011 12:40:00 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/#comment-2877</guid>
		<description>Thanks! This is one thing I didn&#039;t know. </description>
		<content:encoded><![CDATA[<p>Thanks! This is one thing I didn&#8217;t know. </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Vucica</title>
		<link>http://codereflect.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/comment-page-1/#comment-2876</link>
		<dc:creator>Ivan Vucica</dc:creator>
		<pubDate>Sat, 28 May 2011 12:39:00 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/#comment-2876</guid>
		<description>No, you can&#039;t. First of all, scanf() with format &quot;%s&quot; goes until first whitespace. It cannot read in &quot;a string with spaces&quot;; that would produce just &quot;a&quot;.

Second, you have a beginner&#039;s mistake in there:

scanf(&quot;%s&quot;,&amp;name);

&quot;name&quot; is already a pointer, why are you the address of the pointer?</description>
		<content:encoded><![CDATA[<p>No, you can&#8217;t. First of all, scanf() with format &#8220;%s&#8221; goes until first whitespace. It cannot read in &#8220;a string with spaces&#8221;; that would produce just &#8220;a&#8221;.</p>
<p>Second, you have a beginner&#8217;s mistake in there:</p>
<p>scanf(&#8220;%s&#8221;,&amp;name);</p>
<p>&#8220;name&#8221; is already a pointer, why are you the address of the pointer?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Vucica</title>
		<link>http://codereflect.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/comment-page-1/#comment-2875</link>
		<dc:creator>Ivan Vucica</dc:creator>
		<pubDate>Sat, 28 May 2011 12:37:00 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/#comment-2875</guid>
		<description>You can&#039;t compare C strings like that. Maybe you meant:

while (!strcmp(fgets(text, sizeof(text), stdin), &quot;[^n]&quot;);

althought I have no idea what you meant by that.</description>
		<content:encoded><![CDATA[<p>You can&#8217;t compare C strings like that. Maybe you meant:</p>
<p>while (!strcmp(fgets(text, sizeof(text), stdin), &#8220;[^n]&#8220;);</p>
<p>althought I have no idea what you meant by that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://codereflect.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/comment-page-1/#comment-2852</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Mon, 06 Dec 2010 16:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/#comment-2852</guid>
		<description>#include 
#include 
int main()
{
   char text[100];     /* Buffer for a line of input. */
   char filename[14];
   FILE *f; 
   printf(&quot;Enter a file name please:n&quot;);
   scanf(&quot;%s&quot;,&amp;filename);
   while ( fgets( text, sizeof(text), stdin ) == &quot;[^n]&quot; );
   printf(&quot;Enter your text: &quot;);
   while ( fgets( text, sizeof(text), stdin ) == &quot;[^n]&quot; );
   f=fopen(filename,&quot;w&quot;);
   fprintf(f,&quot;%s&quot;,text);
   fclose(f);
   system(&quot;Pause&quot;);
}

This should work 100% :)</description>
		<content:encoded><![CDATA[<p>#include<br />
#include<br />
int main()<br />
{<br />
   char text[100];     /* Buffer for a line of input. */<br />
   char filename[14];<br />
   FILE *f;<br />
   printf(&#8220;Enter a file name please:n&#8221;);<br />
   scanf(&#8220;%s&#8221;,&amp;filename);<br />
   while ( fgets( text, sizeof(text), stdin ) == &#8220;[^n]&#8221; );<br />
   printf(&#8220;Enter your text: &#8220;);<br />
   while ( fgets( text, sizeof(text), stdin ) == &#8220;[^n]&#8221; );<br />
   f=fopen(filename,&#8221;w&#8221;);<br />
   fprintf(f,&#8221;%s&#8221;,text);<br />
   fclose(f);<br />
   system(&#8220;Pause&#8221;);<br />
}</p>
<p>This should work 100% <img src='http://codereflect.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://codereflect.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/comment-page-1/#comment-2851</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Mon, 06 Dec 2010 16:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/#comment-2851</guid>
		<description>#include 
#include 
int main()
{
   char text[100];     /* Buffer for a line of input. */
   char filename[14];
   FILE *f; 
   printf(&quot;Enter a file name please:n&quot;);
   scanf(&quot;%s&quot;,&amp;filename);
   while ( fgets( text, sizeof(text), stdin ) == &quot;[^n]&quot; );
   printf(&quot;Enter your text: &quot;);
   while ( fgets( text, sizeof(text), stdin ) == &quot;[^n]&quot; );
   f=fopen(filename,&quot;w&quot;);
   fprintf(f,&quot;%s&quot;,text);
   fclose(f);
   system(&quot;Pause&quot;);
}

This should work 100% ;)</description>
		<content:encoded><![CDATA[<p>#include<br />
#include<br />
int main()<br />
{<br />
   char text[100];     /* Buffer for a line of input. */<br />
   char filename[14];<br />
   FILE *f;<br />
   printf(&#8220;Enter a file name please:n&#8221;);<br />
   scanf(&#8220;%s&#8221;,&amp;filename);<br />
   while ( fgets( text, sizeof(text), stdin ) == &#8220;[^n]&#8221; );<br />
   printf(&#8220;Enter your text: &#8220;);<br />
   while ( fgets( text, sizeof(text), stdin ) == &#8220;[^n]&#8221; );<br />
   f=fopen(filename,&#8221;w&#8221;);<br />
   fprintf(f,&#8221;%s&#8221;,text);<br />
   fclose(f);<br />
   system(&#8220;Pause&#8221;);<br />
}</p>
<p>This should work 100% <img src='http://codereflect.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Themanish43</title>
		<link>http://codereflect.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/comment-page-1/#comment-2838</link>
		<dc:creator>Themanish43</dc:creator>
		<pubDate>Wed, 20 Oct 2010 15:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/#comment-2838</guid>
		<description>printf(&quot;Please Enter Your Name:n&quot;);
char sname[200];
scanf(&quot;%s[^n]&quot;,sname);


ll it work?</description>
		<content:encoded><![CDATA[<p>printf(&#8220;Please Enter Your Name:n&#8221;);<br />
char sname[200];<br />
scanf(&#8220;%s[^n]&#8220;,sname);</p>
<p>ll it work?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: air force 1 shoes</title>
		<link>http://codereflect.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/comment-page-1/#comment-2532</link>
		<dc:creator>air force 1 shoes</dc:creator>
		<pubDate>Fri, 09 Jul 2010 07:46:00 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/#comment-2532</guid>
		<description>&quot;Here &lt;a href=&quot;http://www.air-jordan-21.net&quot; &gt;air jordan 21&lt;/a&gt;  products xx, has fashion model, superior quality and service, cheap  price and updates quickly.I support strongly always! I want to buy XX, I hesitate  to select which style more better.Hope your unique recommends.
&quot;
</description>
		<content:encoded><![CDATA[<p>&#8220;Here <a href="http://www.air-jordan-21.net" >air jordan 21</a>  products xx, has fashion model, superior quality and service, cheap  price and updates quickly.I support strongly always! I want to buy XX, I hesitate  to select which style more better.Hope your unique recommends.<br />
&#8220;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paulo R Stradioti</title>
		<link>http://codereflect.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/comment-page-1/#comment-2515</link>
		<dc:creator>Paulo R Stradioti</dc:creator>
		<pubDate>Wed, 16 Jun 2010 21:28:06 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/#comment-2515</guid>
		<description>Hello,&lt;br&gt;&lt;br&gt;Thanks for sharing such a smart and easy way to do a simple task!&lt;br&gt;&lt;br&gt;Paulo</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Thanks for sharing such a smart and easy way to do a simple task!</p>
<p>Paulo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stepnowski</title>
		<link>http://codereflect.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/comment-page-1/#comment-1990</link>
		<dc:creator>Stepnowski</dc:creator>
		<pubDate>Sat, 29 Aug 2009 07:40:34 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/#comment-1990</guid>
		<description>I would like to see more blog entries like this one</description>
		<content:encoded><![CDATA[<p>I would like to see more blog entries like this one</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bubba</title>
		<link>http://codereflect.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/comment-page-1/#comment-1987</link>
		<dc:creator>Bubba</dc:creator>
		<pubDate>Thu, 30 Jul 2009 15:06:23 +0000</pubDate>
		<guid isPermaLink="false">http://sarathc.wordpress.com/2006/10/25/scanf-in-c-reading-single-line-of-text-using-scanf-function/#comment-1987</guid>
		<description>Or, we can just use

#include
int main()
{
char name[99];
printf(&quot;What is your name? &quot;);
scanf(&quot;%s&quot;,&amp;name);
printf(&quot;Hello, %s. How are you?\n&quot;,name);
return(0);
}

Same result.</description>
		<content:encoded><![CDATA[<p>Or, we can just use</p>
<p>#include<br />
int main()<br />
{<br />
char name[99];<br />
printf(&#8220;What is your name? &#8220;);<br />
scanf(&#8220;%s&#8221;,&amp;name);<br />
printf(&#8220;Hello, %s. How are you?\n&#8221;,name);<br />
return(0);<br />
}</p>
<p>Same result.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

