0

What are string data types in c++.?define with example program?

string

15th Feb 2017, 5:04 PM
hashaam
hashaam - avatar
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.👻
15th Feb 2017, 5:22 PM
Mr.Robot
Mr.Robot - avatar
+ 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
15th Feb 2017, 7:56 PM
Francisco Gonzalez
Francisco Gonzalez - avatar
0
it is good but difficult to understand... BTW thanks for help
15th Feb 2017, 7:58 PM
hashaam
hashaam - avatar