title: How to cout limited characters of a string in C++?
body: <p>I am building a program for a student percentage generator. In the program, I want to print the entered name of the student upto specific characters, say 5. I am using an array string.
  I have searched alot but could not find a proper answer to the problem.</p>
  
  <p>I have tried using only arrays. [I am a beginner]</p>
  
  <pre><code>#include&lt;iostream&gt;
  
  using namespace std;
  int main()
  {
    cout&lt;&lt;"Enter your name:";
    char name[20]; 
    cin&gt;&gt;name; //want to show only first 5 name letters
    cout&lt;&lt;"Your name is "&lt;&lt;name;
  
    return 0;
  }
  </code></pre>
  
  <p>I want it to collect the data entered by user and print the entered data upto 5 characters. Is there any way to do it? </p>