title: How to write C program that accepts user input that contain both integers and punctuation characters?
body: <p><em>Solution</em></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
   int main()
  {
      char value[50];
      char *end;
      int sum = 0;
      long conv;
      while(conv != 0 )
      {
              printf("Enter a measurement and unit(Ex: 4' or 3\";0' or 0\" when done): ");
              fgets(value, 50, stdin);
              conv = strtol(value, &amp;end, 10);
              if(strstr(value, "\'") != NULL)
              {
                      conv = strtol(value, &amp;end, 10);
                      sum = sum + (conv*12);
              }
              else if(strstr(value, "\"") != NULL)
              {
                      conv = strtol(value, &amp;end, 10);
                      sum = sum + conv;
              }
      }
      printf("Total: %d, %s\n", sum, "inches" );
      return 0;
  }
  </code></pre>
  
  <p><em>UPDATE</em> Still having problems with new program..unsure where to go from here. It is accepting numbers and quotes, but it keeps multiplying any number I type in by 12 when it should only do that if I enter a single quote to specify feet.
  <em>UPDATE2</em> Here are the functions for Assembly that we should keep in mind for writing the C program:</p>
  
  <pre><code>void printStr(char *)
   Arguments:
   edi = address of null-terminated string to print
   Returns:
      Nothing
  
  void printUInt(unsigned)
   Arguments:
   edi = Unsigned integer to print
   Returns:
    Nothing
  
   char getchar()
    Arguments:
    None
    Returns:
     eax = the next character
  
   uinsigned readUInt()
   Arguments:
   None
   Returns:
    eax = an unsigned int read from stdin.
         (eax is 0 on error)
  </code></pre>
  
  <p>I must write a C program which prompts the user to enter a measurement(number) and unit( ' or ", which represent feet or inches) and then prints out the Total length in inches AFTER the user enters a length of '0' which acts as a sentinel value.</p>
  
  <p>This program is only needed to act as a way for me to then build an Assembly program with a similar structure. The thing is, it must be built around 4 functions that would be called to help perform some of the operations.</p>
  
  <p>So my C program should be built similarly with those functions in mind. Here's what I have:</p>
  
  <p>Here is my program:</p>
  
  <p>UPDATED:</p>
  
  <pre><code>int main()
  {
      char value[50];
      char *end;
      int sum = 0;
      long conv;
      while(conv != 0)
      {
              printf("Enter a measurement and unit: ");
              fgets(value, 50, stdin);
              conv = strtol(value, &amp;end, 10);
              if(value[1]='\'')
              {
                      sum = sum + (conv*12);
              }
              if(value[1]='\"')
              {
                      sum = sum + conv;
              }
      }
      printf("Total: %d\n", sum);
      return 0;
  }
  </code></pre>
  
  <p>OLD:</p>
  
  <pre><code>int main()
  {
      int sum = 0;
      int value;
      char symbol;
  
      while(value != 1)
      {
              printf("Enter measurement and unit: ");
              scanf("%d,%d", &amp;value, &amp;symbol);
  
              if(symbol == "'")
              {
                      sum = sum + value*12;
              }
              else if(symbol == ''' )
              {
                      sum = sum + value;
              }
  
              sum = sum + value;
      }
      printf("Total: %d", sum);
      return 0;
  }
  </code></pre>
  
  <p>I hope I have enough information here for someone to help me even though I know we're missing the complete functions for time being. And I know the IA32 assembly conversion is not my main question and I think I will save that for another if I get stuck, but I hope getting this High-Level language program corrected will get me going in the right direction. Thanks in advance!</p>