<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Problems with user input functions' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Problems with user input functions' posted on the 'Beginner C/C++' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 20:07:22 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 20:07:22 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Problems with user input functions</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/414792/414792/problems-with-user-input-functions/</link>
      <description>Hey guys, I am using scanf() to input values for a structure and it does this weird thing where it will "skip" input lines. I have no idea why this is happening. Here is my code:&lt;br /&gt;
&lt;br /&gt;
printf("Name: ");&lt;br /&gt;
scanf("%s,new_patient.name);&lt;br /&gt;
&lt;br /&gt;
I have about 9 input statements just like this one. They are one after another with combination of string and integer inputs. I don't feel like typing them all out. It's supposed to be input for a patient being admitted to a hospital.&lt;br /&gt;
&lt;br /&gt;
Heres my output:&lt;br /&gt;
&lt;br /&gt;
Name: Lawrence Aiello&lt;br /&gt;
Date of birth: Date of your last physical: &lt;br /&gt;
December 3&lt;br /&gt;
Height (in inches): Weight (be honest!): &lt;br /&gt;
&lt;br /&gt;
See how it skips date of birth and height? I need help fixing this I have no idea what to do. Thanks in advance.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/414792/414792/problems-with-user-input-functions/</guid>
      <pubDate>Mon, 22 Mar 2010 17:29:22 -0700</pubDate>
      <category>Beginner C/C++</category>
    </item>
    <item>
      <title>Re: Problems with user input functions</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/414792/414793/re-problems-with-user-input-functions/#414793</link>
      <description>Probably the format string is wrong. The best thing you can do is just copy the relevant code here and put it between code tags.</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/414792/414793/re-problems-with-user-input-functions/#414793</guid>
      <pubDate>Mon, 22 Mar 2010 19:40:19 -0700</pubDate>
      <category>Beginner C/C++</category>
    </item>
    <item>
      <title>Re: Problems with user input functions</title>
      <link>http://www.programmersheaven.com/mb/beginnercpp/414792/415343/re-problems-with-user-input-functions/#415343</link>
      <description>scanf is somewhat problematic in this type of thing, especially where you are mixing different types of inputs.  But the first thing you have to realize is that scanf STOPS on white space.  So if you have&lt;br /&gt;
&lt;br /&gt;
scanf("%s", name);  where 'name' is a string and in response you put&lt;br /&gt;
Douglas White&lt;br /&gt;
&lt;br /&gt;
then name will only be Douglas.&lt;br /&gt;
White would then go to feed other inputs later on.&lt;br /&gt;
&lt;br /&gt;
You should use fgets instead of scanf.  It does NOT stop on white space.&lt;br /&gt;
But it only inputs into a string.  Use it like&lt;br /&gt;
&lt;br /&gt;
fgets(string, 100, stdin);&lt;br /&gt;
&lt;br /&gt;
This reads chars into 'string' up to a max of 100 characters, or until EOL or EOF (end of line or end of file).  If you need integer&lt;br /&gt;
or floating point values from this use&lt;br /&gt;
double x;&lt;br /&gt;
int n;&lt;br /&gt;
n = atoi(string);&lt;br /&gt;
or &lt;br /&gt;
x = atof(string);&lt;br /&gt;
&lt;br /&gt;
Be sure to #include &amp;lt;stdlib.h&amp;gt; and &amp;lt;stdio.h&amp;gt; for these.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/beginnercpp/414792/415343/re-problems-with-user-input-functions/#415343</guid>
      <pubDate>Sun, 11 Apr 2010 16:34:35 -0700</pubDate>
      <category>Beginner C/C++</category>
    </item>
  </channel>
</rss>