GATE (Graduate Aptitude Test in Engineering) Computer Science & IT (CS) Programming and Data Structures-Arrays Study Material (Page 4 of 4)

Choose Programs:

🎓 Study Material (1190 Notes): 2024-2025 Syllabus

Rs. 1000.00 -OR-

3 Year Validity (Multiple Devices)

Topic-wise Notes & SampleDetails

🎯 302 Numeric, 2894 MCQs (& PYQs) with Full Explanations (2024-2025 Exam)

Rs. 650.00 -OR-

3 Year Validity (Multiple Devices)

CoverageDetailsSample Explanation

Help me Choose & Register (Watch Video) Already Subscribed?

Strings: Dealing with Multiple Strings

Edit

There are many cases where multiple strings are manipulated in the program. For example, when one string is compared with the other string or checking if one string is assigned to another string etc. The C ++ string object contains many member functions which can be used for operations involving multiple strings. Let us try to see how those member functions can be used in a program.

Using Operators + Operator for Concatenation

The first operator function provided for string object is operator + () which allows a programmer to use + to concatenate two strings. Here is an example.

  1. string String1 =“ Chirag throw a ball ” ;
  2. string String2 ( “ Cat jumps over ” ) ;
  3. string String3 =String1 +String2;
  4. cout<<String3;

output:

Chirag…

… (272 more words) …

Subscribe (by clicking here) to view full notes and track progress.

Strings: Using Functions with Strings

Edit

Now we will see a few functions which can help us deal with multiple strings.

Function Compare ()

The C ++ does not have the strcmp function for the string objects but a similar compare () function which provides similar functionality. Exactly like strcmp, …

… (671 more words) …

Subscribe (by clicking here) to view full notes and track progress.