Programming can be fun, so can cryptography; however they should not be combined. Kreitzberg and Shneiderman
String represent sequences of characters which can be manipulate string operations easily. The string can be used to represent ASCII or wide characters.
![]() |
Supports all the operations related with strings. |
![]() |
String class is an instantiation of the basic_string class template. |
![]() |
Wstring supports to store UTF-16 text on Windows and UTF-32 on most Unix-like platforms. |
![]() |
It can be constructed from a C-style string. |
#include "stdafx.h" #include < iostream > #include < string > using namespace std; int _tmain(int argc, _TCHAR* argv[]) { string string1 = "Hello "; string string2 = " World!"; cout << "String one:" << string1 << endl; cout << "String two:" << string2 << endl << endl; string addtwostrings = string1 + string2; cout << "Add two strings :" << addtwostrings << endl; string string3 = "Hello "; cout << "Compare the string1 and string2" << endl; if (string1 == string2) cout << "string1 and string2 are equal"; else cout << "string1 and string2 are Not equal"; cout << endl << endl; cout << "Compare the string1 and string3" << endl; if (string1 == string3) cout << "string1 and string3 are equal" << endl; return 0; }
String one: Hello String two: World! Add two strings :Hello World! Compare the string1 and string2 string1 and string2 are Not equal Compare the string1 and string3 string1 and string3 are equal
When you want handle the array of characters frequently, you can use strings. You can always prefer to use strings instead of char*. When the string class doesn’t provide any functionality, you can use char array.
0 Comments