Write a C++ program to read and display an entire line entered by user.

Note: If you want to consider space in your string input then please use cin.get(string_name, string_size) format to take input like in the below program.


#include <iostream>
using namespace std;
int main()
{
    char name[25];
    cout<< "Enter a string to be display: ";
    cin.get(name, 25);
    cout<< "You entered a string to display is : " ;
    cout<< name;
    cout<< endl;
    return 0;
}

Program output is tested on www.jdoodle.com

Output:
Enter a string to be display: Mukesh Rajput
You entered a string to display is : Mukesh Rajput



Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

1 comments:

  1. Hello
    You have any idea how to integrate jdoodle compiler API in java web app

    ReplyDelete