title: Scrolling text in C
body: <p>I would like to scroll a text continuously in the screen. For example, </p>
  
  <pre><code>text = "Hello, how are you"
  </code></pre>
  
  <p>The output should be:</p>
  
  <pre>
  Hello, how are you Hello, how are you
  Hello, how are you Hello, how are you
  </pre>
  
  <p>and rotating from right to left.</p>
  
  <p>So far I have compiled this:</p>
  
  <pre class="lang-c prettyprint-override"><code>#include &lt;curses.h&gt;
  #include &lt;unistd.h&gt; // For sleep()
  #include &lt;string.h&gt; // For strlen()
  
  int main(int argc, char *argv[]) {
  
      char *text = argv[1];
      char *text = "Hello, how are you";
      int text_length;
      int i, max_x, max_y;
  
      // Get text length
      text_length = strlen(text);
  
      // Initialize screen for ncurses
      initscr();
      // Don't show cursor
      curs_set(0);
      // Get terminal dimensions
      //   getmaxyx(stdscr, max_y, max_x);
      // Clear the screen
      clear();
  
      // Scroll text back across the screen
  
      while (1) {
          getmaxyx(stdscr, max_y, max_x);
  
          if ((max_x - text_length) &lt;= 1)
              i = max_x;
          else
              i = (max_x - text_length);
  
          for (i; i &gt; 0; i--) {
              clear();
  
              mvaddstr(0, i, text);
              refresh();
              usleep(20000);
          }
      }
      // Wait for a keypress before quitting
      getch();
  
      endwin();
  
      return 0;
  }
  
  Can anybody help to change the code and do that?
  
  </code></pre>