Sunday, 31 January 2016

Getting Started with Strings in Cpp - Reading a string and displaying it

This is a simple Cpp Program to read and display the content of the string.

Download Code


#include <iostream>
#include <string.h>

using namespace std;

int main()
    char name[40];
    cout << "Enter any name(String) : \t";
    cin.get(name , 40);
    cout << "\nThe length of the string you entered is : \t" << strlen(name) << endl;
    return 0;


Cpp Program - Reading and displaying a string