title: How do I get my linked list to display on one line and not create a new line each time? C++
body: <p>So I need help on making the program display the linked list in only one line with nothing in between them. I also need to the use _getch(), getch() or getchar() functions not cin or something similar, the current program uses the _getch() function.</p>
  <p>I'll provide my code, output and desired output.
  Thank you for the help in advance.</p>
  <p>Code:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  #include &lt;string&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  struct Node {
      std::string data{};
      Node* next{ nullptr };
  };
  
  void addToList(Node*&amp; head, Node*&amp; tail) {
      bool quit{ false };
      std::string temp{};
      Node* current{ nullptr };
  
      while (!quit) {
          temp = _getch();
  
          if (temp == &quot;quit&quot;) {
              std::cout &lt;&lt; &quot;\tQuitting submenu.\n&quot;;
              quit = true;
          }
          else {
              // Allocate the new node here
              current = new Node;
              current-&gt;data = temp;
  
              if (tail) {
  
                  tail-&gt;next = current;
                  tail = current;
              }
              else {
                  head = current;
                  tail = current;
              }
  
              std::stringstream ss;
              for (current = head; current; current = current-&gt;next) {
              ss &lt;&lt; current-&gt;data;
              }
  
              std::cout &lt;&lt; &quot;+------------+&quot; &lt;&lt; std::endl;
              std::cout &lt;&lt; &quot;|&quot; &lt;&lt; std::setw(12) &lt;&lt; ss.str() &lt;&lt; &quot;|&quot; &lt;&lt; std::endl;
              std::cout &lt;&lt; &quot;+------------+&quot; &lt;&lt; std::endl &lt;&lt; std::endl;
          }
      }
  }
  
  int main() {
      bool quit = false;
      int choice = 0;
      Node* head = nullptr;
      Node* tail = nullptr;
  
      while (!quit) {
          std::cout &lt;&lt; &quot;1. add to list, 2. quit:\n&quot;;
          std::cin &gt;&gt; choice;
          switch (choice) {
          case 1:
              addToList(head, tail);
              break;
          case 2:
              std::cout &lt;&lt; &quot;Quitting main menu.\n&quot;;
              quit = true;
              break;
          default:
              std::cout &lt;&lt; &quot;That is not a valid input, quitting program.\n&quot;;
              quit = true;
          }
      }
      for (auto tmp{ head }; tmp;) {
          tmp = tmp-&gt;next;
          delete head;
          head = tmp;
      }
  }
  </code></pre>
  <p>Output:</p>
  <pre><code>+------------+
  |           3|
  +------------+
  
  +------------+
  |         334|
  +------------+
  
  +------------+
  |      334345|
  +------------+
  
  +------------+
  |  3343453456|
  +------------+
  </code></pre>
  <p>Desired Output:</p>
  <pre><code>+------------+
  |           3|
  +------------+
  
  +------------+
  |          34|
  +------------+
  
  +------------+
  |         345|
  +------------+
  
  +------------+
  |        3456|
  +------------+
  </code></pre>