C++ Program to demonstrate String datatype [DEVCPP/GCC]


STRING DATATYPE

In C++, strings are not a built-in data type, but rather a Standard Library facility. The standard C++ library provides a string class type that supports all the operations possible through character array and additional functionality.

PROGRAM

//Program to initialize string and display it

#include <iostream>
#include <string>

using namespace std;

int main()
{
string  s1("TECH"); //Through Constructor

string  s2;
cout<<"ENTER STRING: ";
cin>>s2; //Through Input From User

string  s3(5,'+'); //Through Parameterized Constructor

cout<< "\n STRING 1: "<<s1;
cout<< "\n STRING 2: "<<s2;
cout<< "\n STRING 3: "<<s3;

return 0;
}

OUTPUT

C++ Program to demonstrate String datatype with output

Share this

Related Posts

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer

FIND US ON FACEBOOK!