MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

C++ language

Strings in C++
Previous Home Next

In C++, the std::string class is a general explanation for a string of text. This class reduce more problems introduced with C-style strings with putting the vouchment of flashback masterdom on the string class nay than on the programmer. The class gives few typical string operations as similitude, link, search and replace, and a function for obtaining substrings. that can be fabricated by a C style string, and a C style string can also be obtained from it.

#include <string>
using namespace std;

char greeting[5] = {'N', 'I', 'T', 'I','S','H', '\0'};

char greeting[] = "NITISH";
// Example
#include <iostream>
#include <string>
using namespace std;
#include <boost/regex.hpp>
int main ()
{
boost::regex fullname_regex ("[AZ]+[az]*, [AZ][az]*");
string name;
cout << "Enter you full name: " << flush;
getline (cin, name);
if (! regex_match (name, fullname_regex))
{
cout << "Error: name not entered correctly" << endl;
}
return 0;
}

 

String class:-

Strings are objects that show series of characters.

C++ provides a easy, secure optional to using char string to handle strings. The C++ string class, portion of the std::namespace, order you to manipulate strings securely.

The standard string class give recourse for like objects by an interface same to that a standard character of bytes, but addition characteristics especially designed to operate by strings of one-byte characters. The string class is an recommence of the basic string class template that uses char like its character type, by default char traits and destinator types.C++ strings allow you to outright initialize, entrust, comparison, and reassign by intuitive operators, also printing and reading , like shown in the example below:

#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str1 = "Nitish";
string str2 = "Kumar";
string str3;
int len ;
                               // copy str1 into str3
str3 = str1;
cout << "str3 : " << str3 << endl;
                                      // concatenates str1 and str2
str3 = str1 + str2;
cout << "str1 + str2 : " << str3 << endl;
                                    // total lenghth of str3 after concatenation
len = str3.size();
cout << "str3.size() : " << len << endl;
return 0;
}

That this class handles bytes freely of the encoding used: If used to handle series of various byte or character length characters all members of this class, like its iterators, will still operate in terms of bytes

Previous Home Next