how to make a string output letters as you type them in
<p>this program is supposed to output to the console a string of letters i type in, for example if i type in "im hungry" then its supposed to output im hungry to the console in a matrix for, if something i type in is too long then it carries over to the next line of the matrix</p>

<p>heres the code i have so far:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;
#define N 6

//
// fill:
//
void fill(string s, int M[][N], int ROWS, int COLS)
{
    int i, r, c;
    s= "x";

    for (i=0, r=0; r &lt; ROWS; r++)
    {
        for (c=0; c &lt; COLS; c++)
        {
             M[r][c] = s[i];  // store ith character into matrix:

             i++; // next character:
             if (i == s.length())  // start-over if that was last char:
             i = 0;
        }
   }
} 

void print(int M[][N], int ROWS, int COLS)
{
  string s;
  s= "x";
  int r, c;
  for(r=0; r&lt; ROWS; r++)
  {
     for(c=0; c &lt; COLS; c++)
     {
       cout&lt;&lt;(char)M[r][c];
     }

 cout &lt;&lt;endl; 
  }
 }

//
// main:
//
int main()
{
    string s;
    getline(cin,s);
    int  M[N][N];
    int  M2[N][N];
    int  row, col, ROWS, COLS;
    fill(s, M, 1, 1);
    print(M, ROWS, COLS);

return 0;
 }
</code></pre>

<p>instead of outputting what I type in, it keeps outputting a matrix of random characters (same no matter what I type in) any suggestions on how I can fix this?</p>
