title: How to return a C-String from a function and display it
body: <p>I can't get my program to display the whole c-string, it only displays the first letter! I am trying to write a function that asks the user to input 2 c-strings. I then have a separate function to determine which c-sting is greater alphabetically, and another to display. Every time it displays the c-strings it only displays the first letter though. I can't figure out what I'm doing wrong. I need it to display the whole c-string.</p>
  <p>Here is the function that asks the user for two c-strings:</p>
  <pre><code>const char *getData(char *c, char *d)
  {
      cout &lt;&lt; &quot;Enter the first c-string: &quot;;
      cin.ignore();
      cin.getline(c, 50);
      cout &lt;&lt; &quot;Enter the second c-string: &quot;;
      cin.getline(d, 50);
      return c, d;
  }
  </code></pre>
  <p>Here is the function that compares the c-strings</p>
  <pre><code>const char findBigger(char *c, char *d)
  {
      if (strcmp(c, d) == 0)
          return *c;
      else if (strcmp(c, d) &lt; 0)
          return *c;
      else if (strcmp(c, d) &gt; 0)
          return *d;
  }
  </code></pre>
  <p>And here is the function that displays the inputs and the greater c-string</p>
  <pre><code>void displayBigger(const char *c, const char *d, const char *maxChar)
  {
      cout &lt;&lt; &quot;The first c-string is &quot; &lt;&lt; c &lt;&lt; endl;
      cout &lt;&lt; &quot;The second char is &quot; &lt;&lt; d &lt;&lt; endl;
      cout &lt;&lt; &quot;The bigger value is &quot; &lt;&lt; maxChar &lt;&lt; endl;
      cout &lt;&lt; &quot;__________________________________________&quot; &lt;&lt; endl;
  }
  </code></pre>
  <p>In <code>main()</code> I have</p>
  <pre><code>char first[50],
  second[50]'
  maxArray[50];
  getData(first, second);
  *maxArray = findBigger(first, second);
  displayBigger(*first, *second, *maxArray);
  </code></pre>
  <p>The output of the program is:</p>
  <pre><code>Enter the first c-string: apple pie
  Enter the second c-string: peach pie
  The first char is a
  The second char is p
  The bigger value is a
  __________________________________________
  </code></pre>
  <p>How do I get it to print the whole c-string? It should display &quot;apple pie&quot; and &quot;peach pie&quot;</p>