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.
I have tried using only arrays. [I am a beginner]
#include<iostream>
using namespace std;
int main()
{
cout<<"Enter your name:";
char name[20];
cin>>name; //want to show only first 5 name letters
cout<<"Your name is "<<name;
return 0;
}
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?