0
What are string data types in c++.?define with example program?
string
3 Respostas
+ 7
Strings are group of characters.
example:
string example="hello world";
P.s: #include<string.h> should be defined if you want to use string in your program.👻
+ 1
string is a template specialization of basic_string template.
It is defined in <string> as:
typedef basic_string<char> string;
It is part of the std namesapce.
It is used to store sequences of "char"
using namespace std;
string salute("Hello ");
string who ("World");
string text = salute + who; // text contains "Hello World"
cout << text.size(); // prints 11
text.clear(); // text contains ""
text.append(salute);
text += who; // text contains "Hello World"
cout << text[0]; // prints "H"
text.replace(6,5,"Sololearn"); // text contains "Hello Sololearn"
Strings can be used with streams
using namespace std;
string name;
cin >> name;
cout << name
0
it is good but difficult to understand... BTW thanks for help