- A Brief Intro To C++ & Its History
- The Detailed History & Timeline Of C++ (With Infographic)
- Importance Of C++
- Versions Of C++ Language
- Structure Of A C++ Program
- Comparison With Other Popular Programming Languages
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Variables In C++?
- Declaration & Definition Of Variables In C++
- Variable Initialization In C++
- Rules & Regulations For Naming Variables In C++ Language
- Different Types Of Variables In C++
- Different Types of Variable Initialization In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Primitive Data Types In C++?
- Derived Data Types In C++
- User-Defined Data Types In C++
- Abstract Data Types In C++
- Data Type Modifiers In C++
- Declaring Variables With Auto Keyword
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- Structure Of C++ Program: Components
- Segment 1: Documentation Section Of Structure Of C++ Program (With Example)
- Segment 2: Preprocessing & Namespace (Linking) Section Of CPP Program
- Segment 3: Definition Section In Structure of a C++ Program (With Examples)
- Segment 4: Main Function In Structure Of A C++ Program (With Example)
- Compilation & Execution Of C++ Programs | Step-by-Step Explanation
- Explaining Structure Of C++ Program With Suitable Example
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What is Typedef in C++?
- The Role & Applications of Typedef in C++
- Basic Syntax for typedef in C++
- How Does typedef Work in C++?
- How to Use Typedef in C++ With Examples? (Multiple Data Types)
- The Difference Between #define & Typedef in C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Strings In C++?
- Types Of Strings In C++
- How To Declare & Initialize C-Style Strings In C++ Programs?
- How To Declare & Initialize Strings In C++ Using String Keyword?
- List Of String Functions In C++
- Operations On Strings Using String Functions In C++
- Concatenation Of Strings In C++
- How To Convert Int To Strings In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is String Concatenation In C++?
- How To Concatenate Two Strings In C++ Using The ‘+' Operator?
- String Concatenation Using The strcat( ) Function
- Concatenation Of Two Strings In C++ Using Loops
- String Concatenation Using The append() Function
- C++ String Concatenation Using The Inheritance Of Class
- Concatenate Two Strings In C++ With The Friend and strcat() Functions
- Why Do We Need To Concatenate Two Strings?
- How To Reverse Concatenation Of Strings In C++?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is Find In String C++?
- What Is A Substring?
- How To Find A Substring In A String In C++?
- How To Find A Character In String C++?
- Find All Substrings From A Given String In C++
- Index Substring In String In C++ From A Specific Start To A Specific Length
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Pointers In C++?
- Pointer Declaration In C++
- How To Initialize And Use Pointers In C++?
- Different Types Of Pointers In C++
- References & Pointers In C++
- Arrays And Pointers In C++
- String Literals & Pointers In C++
- Pointers To Pointers In C++ (Double Pointers)
- Arithmetic Operation On Pointers In C++
- Advantages Of Pointers In C++
- Some Common Mistakes To Avoid With Pointers In Cpp
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- Understanding Pointers In C++
- What Is Pointer To Object In C++?
- Declaration And Use Of Object Pointers In C++
- Advantages Of Pointer To Object In C++
- Pointer To Objects In C++ With Arrow Operator
- An Array Of Objects Using Pointers In C++
- Base Class Pointer For Derived Class Object In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is 'This' Pointer In C++?
- Defining ‘this’ Pointer In C++
- Example Of 'this' Pointer In C++
- Describing The Constness Of 'this' Pointer In C++
- Important Uses Of 'this' Pointer In C++
- Method Chaining Using 'this' Pointer In C++
- C++ Programs To Show Application Of 'This' Pointer
- How To Delete The ‘this’ Pointer In C++?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What is Reference?
- What is Pointer?
- Comparison Table Of C++ Pointer Vs. Reference
- Differences Between Reference And Pointer: A Detailed Explanation
- Why Are References Less Powerful Than Pointers?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- How To Declare A 2D Array In C++?
- C++ Multi-Dimensional Arrays
- Ways To Initialize A 2D Array In C++
- Methods To Dynamically Allocate A 2D Array In C++
- Accessing/ Referencing Two-Dimensional Array Elements
- How To Initialize A Two-Dimensional Integer Array In C++?
- How To Initialize A Two-Dimensional Character Array?
- How To Enter Data In Two-Dimensional Array In C++?
- Conclusion
- Frequently Asked Questions
- What Are Arrays Of Strings In C++?
- Different Ways To Create String Arrays In C++
- How To Access The Elements Of A String Array In C++?
- How To Convert Char Array To String?
- Conclusion
- Frequently Asked Questions
- What is Memory Allocation in C++ & Why Do We Need It?
- How Does Dynamic Memory Allocation Work?
- The new Operator in C++
- The delete Operator in C++
- Dynamic Memory Allocation in C++ | Arrays
- Did You Know: Companies That Ask About Dynamic Memory Allocation
- Dynamic Memory Allocation in C++ | Objects
- Deallocation of Dynamic Memory in C++
- malloc(), calloc(), and free() Functions in C/C++
- Applications of Dynamic Memory Allocation in C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is A Substring In C++ (Substr C++)?
- Example for substr() in C++ | Finding Substring Using Positive and Negative Indices
- Understanding substr() Basics with Examples
- Use Cases/ Examples of substr() in C++
- How to Get a Substring Before a Character Using substr() in C++?
- Use substr() in C++ to Print all Substrings of a Given String
- Print Sum of all Substrings of a String Representing a Number
- Minimum Value of all Substrings of a String Representing a Number
- Maximum Value of all Substrings of a String Representing a Number
- Points To Remember For Substr In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is Operator In C++?
- Types Of Operators In C++ With Examples
- What Are Arithmetic Operators In C++?
- What Are Assignment Operators In C++?
- What Are Relational Operators In C++?
- What Are Logical Operators In C++?
- What Are Bitwise Operators In C++?
- What Is Ternary/ Conditional Operator In C++?
- Miscellaneous Operators In C++
- Precedence & Associativity Of Operators In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is The New Operator In C++?
- Example To Understand New Operator In C++
- The Grammar Elements Of The New Operator In C++
- Storage Space Allocation
- How Does The C++ New Operator Works?
- What Happens When Enough Memory In The Program Is Not Available?
- Initializing Objects Allocated With New Operator In C++
- Lifetime Of Objects Allocated With The New Operator In C++
- What Is The Delete Operator In C++?
- Difference Between New And Delete Operator In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- Types Of Overloading In C++
- What Is Operator Overloading In C++?
- How To Overload An Operator In C++?
- Overloadable & Non-overloadable Operators In C++
- Unary Operator Overloading In C++
- Binary Operator Overloading In C++
- Special Operator Overloading In C++
- Rules For Operator Overloading In C++
- Advantages And Disadvantages Of Operator Overloading In C++
- Function Overloading In C++
- What Is the Difference Between Operator Functions and Normal Functions?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Operators In C++?
- Introduction To Logical Operators In C++
- Types Of Logical Operators In C++ With Example Program
- Logical AND (&&) Operator In C++
- Logical NOT(!) Operator In C++
- Logical Operator Precedence And Associativity In C++
- Relation Between Conditional Statements And Logical Operators In C++
- C++ Relational Operators
- Conclusion
- Frequently Asked Important Interview Questions:
- Test Your Skills: Quiz Time
- Different Type Of C++ Bitwise Operators
- C++ Bitwise AND Operator
- C++ Bitwise OR Operator
- C++ Bitwise XOR Operator
- Bitwise Left Shift Operator In C++
- Bitwise Right Shift Operator In C++
- Bitwise NOT Operator
- What Is The Meaning Of Set Bit In C++?
- What Does Clear Bit Mean?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- Types of Comments in C++
- Single Line Comment In C++
- Multi-Line Comment In C++
- How Do Compilers Process Comments In C++?
- C- Style Comments In C++
- How To Use Comment In C++ For Debugging Purposes?
- When To Use Comments While Writing Codes?
- Why Do We Use Comments In Codes?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Storage Classes In Cpp?
- What Is The Scope Of Variables?
- What Are Lifetime And Visibility Of Variables In C++?
- Types of Storage Classes in C++
- Automatic Storage Class In C++
- Register Storage Class In C++
- Static Storage Class In C++
- External Storage Class In C++
- Mutable Storage Class In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- Decision Making Statements In C++
- Types Of Conditional Statements In C++
- If-Else Statement In C++
- If-Else-If Ladder Statement In C++
- Nested If Statements In C++
- Alternatives To Conditional If-Else In C++
- Switch Case Statement In C++
- Jump Statements & If-Else In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is A Switch Statement/ Switch Case In C++?
- Rules Of Switch Case In C++
- How Does Switch Case In C++ Work?
- The break Keyword In Switch Case C++
- The default Keyword In C++ Switch Case
- Switch Case Without Break And Default
- Advantages & Disadvantages of C++ Switch Case
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is A For Loop In C++?
- Syntax Of For Loop In C++
- How Does A For Loop In C++ Work?
- Examples Of For Loop Program In C++
- Ranged Based For Loop In C++
- Nested For Loop In C++
- Infinite For Loop In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is A While Loop In C++?
- Parts Of The While Loop In C++
- C++ While Loop Program Example
- How Does A While Loop In C++ Work?
- What Is Pre-checking Process Or Entry-controlled Loop?
- When Are While Loops In C++ Useful?
- Example C++ While Loop Program
- What Are Nested While Loops In C++?
- Infinite While Loop In C++
- Alternatives To While Loop In C++
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Are Loops & Its Types In C++?
- What Is A Do-While Loop In C++?
- Do-While Loop Example In C++ To Print Numbers
- How Does A Do-While Loop In C++ Work?
- Various Components Of The Do-While Loop In C++
- Example 2: Adding User-Input Positive Numbers With Do-While Loop
- C++ Nested Do-While Loop
- C++ Infinitive Do-while Loop
- What is the Difference Between While Loop and Do While Loop in C++?
- When To Use A Do-While Loop?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What are 2D Vectors in C++?
- How to Declare 2D Vectors in C++
- How to Initialize a 2D Vector in C++?
- Creating a 2D Vector in C++ with User Input for Column & Row Size
- Methods for Traversing 2D Vectors in C++
- Interview Spotlight: 2D Vectors in FAANG Interviews
- Printing 2D Vector in C++ Using Nested Loops
- Example C++ Programs for Creating 2D Vectors
- How to Access & Modify 2D Vector Elements in C++?
- Adding Elements to 2D Vector Using push_back() Function
- Removing Elements from Vector in C++ Using pop_back() Function
- Did You Know? Real-World Outage: Crash Cause Linked to 2D Vector Usage
- Advantages of 2D Vectors Over Traditional Arrays
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- How To Print A Vector In C++ By Overloading Left Shift (<<) Operator?
- How To Print Vector In C++ Using Range-Based For-Loop?
- Print Vector In C++ With Comma Separator
- Printing Vector In C++ Using Indices (Square Brackets/ Double Brackets & at() Function)
- How To Print A Vector In C++ Using std::copy?
- How To Print A Vector In C++ Using for_each() Function?
- Printing C++ Vector Using The Lambda Function
- How To Print Vector In C++ Using Iterators?
- Conclusion
- Frequently Asked Questions
- Definition Of C++ Find In Vector
- Using The std::find() Function
- How Does find() In Vector C++ Function Work?
- Finding An Element By Custom Comparator Using std::find_if() Function
- Use std::find_if() With std::distance()
- Element Find In Vector C++ Using For Loop
- Using The find_if_not Function
- Find Elements With The Linear Search Approach
- Conclusion
- Frequently Asked Questions
- What Is Sort() Function In C++?
- Sort() Function In C++ From Standard Template Library
- Exceptions Of Sort() Function/ Algorithm In C++
- The Stable Sort() Function In C++
- Partial Sort() Function In C++
- Sorting In Ascending Order With Sort() Function In C++
- Sorting In Descending Order With Sort Function In C++
- Sorting In Desired Order With Custom Comparator Function & Sort Function In C++
- Sorting Elements In Desired Order Using Lambda Expression & Sort Function In C++
- Types of Sorting Algorithms In C++
- Advanced Sorting Algorithms In C++
- How Does the Sort() Function Algorithm Work In C++?
- Conclusion
- Frequently Asked Questions
- What Is Function Overloading In C++?
- Ways Of Function Overloading In C++
- Function Overloading In C++ Using Different Types Of Parameters
- Function Overloading In C++ With Different Number Of Parameters
- Function Overloading In C++ Using Different Sequence Of Parameters
- How Does Function Overloading In C++ Work?
- Rules Of Function Overloading In C++
- Why Is Function Overloading Used?
- Types Of Function Overloading Based On Time Of Resolution
- Causes Of Function Overloading In C++
- Ambiguity & Function Overloading In C++
- Advantages Of Function Overloading In C++
- Disadvantages Of Function Overloading In C++
- Operator Overloading In C++
- Function Overriding In C++
- Difference Between Function Overriding & Function Overloading In C++
- Conclusion
- Frequently Asked Questions
- What Is An Inline Function In C++?
- How To Define The Inline Function In C++?
- How Does Inline Function In C++ Work?
- The Need For An Inline Function In C++
- Can The Compiler Ignore/ Reject Inline Function In C++ Programs?
- Normal Function Vs. Inline Function In C++
- Classes & Inline Function In C++
- Understanding Inline, __inline, And __forceinline Functions In C++
- When To Use An Inline Function In C++?
- Advantages Of Inline Function In C++
- Disadvantages Of Inline Function In C++
- Why Not Use Macros Instead Of An Inline Function In C++?
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is Static Data Member In C++?
- How To Declare Static Data Members In C++?
- How To Initialize/ Define Static Data Member In C++?
- Ways To Access A Static Data Member In C++
- What Are Static Member Functions In C++?
- Example Of Member Function & Static Data Member In C++
- Practical Applications Of Static Data Member In C++
- Conclusion
- Frequently Asked Questions
- What Is A Constant In C++?
- Ways To Define Constant In C++
- What Are Literals In C++?
- Pointer To A Constant In C++
- Constant Function Arguments In C++
- Constant Member Function Of Class In C++
- Constant Data Members In C++
- Object Constant In C++
- Conclusion
- Frequently Asked Questions(FAQ)
- What is the Friend Function in C++?
- Declaration of Friend Function in C++ with Example
- Characteristics of Friend Function in C++
- Types/ Ways to Implement Friend Function in C++
- Global Friend Function in C++ (Global Function as Friend Function )
- Member Function of Another Class as a Friend Function in C++
- Function Overloading Using Friend Function in C++
- Advantages & Disadvantages of Friend Function in C++
- Interview Spotlight: Friend Functions in Cognizant Interview
- What is a C++ Friend Class?
- A Function Friendly to Multiple Classes
- C++ Friend Class vs. Friend Function in C++
- Some Important Points About Friend Functions and Classes in C++
- Conclusion
- Frequently Asked Questions
- What Is Function Overriding In C++?
- The Working Mechanism Of Function Overriding In C++
- Real-Life Example Of Function Overriding In C++
- Accessing Overriding Function In C++
- Accessing Overridden Function In C++
- Function Call Binding With Class Objects | Function Overriding In C++
- Function Call Binding With Base Class Pointers | Function Overriding In C++
- Advantages Of Function Overriding In C++
- Variations In Function Overriding In C++
- Function Overloading In C++
- Function Overloading Vs Function Overriding In C++
- Conclusion
- Frequently Asked Questions
- Errors In C++
- What Is Exception Handling In C++?
- Exception Handling In C++ Program Example
- C++ Exception Handling: Basic Keywords
- The Need For C++ Exception Handling
- C++ Standard Exceptions
- C++ Exception Classes
- User-Defined Exceptions In C++
- Advantages & Disadvantages Of C++ Exception Handling
- Conclusion
- Frequently Asked Questions
- What Are Templates In C++ & How Do They Work?
- Types Of Templates In C++
- What Are Function Templates In C++?
- C++ Template Functions With Multiple Parameters
- C++ Template Function Overloading
- What Are Class Templates In C++?
- Defining A Class Member Outside C++ Template Class
- C++ Template Class With Multiple Parameters
- What Is C++ Template Specialization?
- How To Specify Default Arguments For Templates In C++?
- Advantages Of C++ Templates
- Disadvantages Of C++ Templates
- Difference Between Function Overloading And Templates In C++
- Conclusion
- Frequently Asked Questions
- Structure
- Structure Declaration
- Initialization of Structure
- Copying and Comparing Structures
- Array of Structures
- Nested Structures
- Pointer to a Structure
- Structure as Function Argument
- Self Referential Structures
- Class
- Object Declaration
- Accessing Class Members
- Similarities between Structure and Class
- Which One Should You Choose?
- Key Difference Between a Structure and Class
- Summing Up
- Test Your Skills: Quiz Time
- What Is A Class And Object In C++?
- What Is An Object In C++?
- How To Create A Class & Object In C++? With Example
- Interview Spotlight: Classes & Objects In Adobe & Pixar Interviews
- Access Modifiers & Class/ Object In C++
- Member Functions Of A Class In C++
- How To Access Data Members And Member Functions?
- Significance Of Class & Object In C++
- Did You Know? The Concept of Classes & Object Powers Major Apps
- What Are Constructors In C++ & Its Types?
- What Is A Destructor Of Class In C++?
- An Array Of Objects In C++
- Object In C++ As Function Arguments
- The this (->) Pointer & Classes In C++
- The Need For Semicolons At The End Of A Class In C++
- Conclusion
- Frequently Asked Questions
- What Are Static Members In C++?
- Static Member Functions in C++
- Ways To Call Static Member Function In C++
- Properties Of Static Member Function In C++
- Need Of Static Member Functions In C++
- Regular Member Function Vs. Static Member Function In C++
- Limitations Of Static Member Functions In C++
- Conclusion
- Frequently Asked Questions
- What Is Constructor In C++?
- Characteristics Of A Constructor In C++
- Types Of Constructors In C++
- Default Constructor In C++
- Parameterized Constructor In C++
- Copy Constructor In C++
- Dynamic Constructor In C++
- Benefits Of Using Constructor In C++
- How Does Constructor In C++ Differ From Normal Member Function?
- Constructor Overloading In C++
- Constructor For Array Of Objects In C++
- Constructor In C++ With Default Arguments
- Initializer List For Constructor In C++
- Dynamic Initialization Using Constructor In C++
- Conclusion
- Frequently Asked Questions
- What Is A Constructor In C++?
- What Is Constructor Overloading In C++?
- Dеclaration Of Constructor Ovеrloading In C++
- Condition For Constructor Overloading In C++
- How Constructor Ovеrloading In C++ Works?
- Examples Of Constructor Overloading In C++
- Lеgal & Illеgal Constructor Ovеrloading In C++
- Types Of Constructors In C++
- Characteristics Of Constructors In C++
- Advantage Of Constructor Overloading In C++
- Disadvantage Of Constructor Overloading In C++
- Conclusion
- Frеquеntly Askеd Quеstions
- What Is A Destructor In C++?
- Rules For Defining A Destructor In C++
- When Is A Destructor in C++ Called?
- Order Of Destruction In C++
- Default Destructor & User-Defined Destructor In C++
- Virtual Destructor In C++
- Pure Virtual Destructor In C++
- Key Properties Of Destructor In C++ You Must Know
- Explicit Destructor Calls In C++
- Destructor Overloading In C++
- Difference Between Normal Member Function & Destructor In C++
- Important Uses Of Destructor In C++
- Conclusion
- Frequently Asked Questions
- What Is A Constructor In C++?
- What Is A Destructor In C++?
- Difference Between Constructor And Destructor In C++
- Constructor In C++ | A Brief Explanation
- Destructor In C++ | A Brief Explanation
- Difference Between Constructor And Destructor In C++ Explained
- Order Of Calling Constructor And Destructor In C++ Classes
- Conclusion
- Frequently Asked Questions
- Test Your Skills: Quiz Time
- What Is Type Conversion In C++?
- What Is Type Casting In C++?
- Types Of Type Conversion In C++
- Implicit Type Conversion (Coercion) In C++
- Explicit Type Conversion (Casting) In C++
- Advantages Of Type Conversion In C++
- Disadvantages Of Type Conversion In C++
- Difference Between Type Casting & Type Conversion In C++
- Application Of Type Casting In C++
- Conclusion
- Frequently Asked Questions
- What Is A Copy Constructor In C++?
- Characteristics Of Copy Constructors In C++
- Types Of Copy Constructors In C++
- When Do We Call The Copy Constructor In C++?
- When Is A User-Defined Copy Constructor Needed In C++?
- Types Of Constructor Copies In C++
- Can We Make The Copy Constructor In C++ Private?
- Assignment Operator Vs Copy Constructor In C++
- Example Of Class Where A Copy Constructor Is Essential
- Uses Of Copy Constructors In C++
- Conclusion
- Frequently Asked Questions
- Why Do You Need Object-Oriented Programming (OOP) In C++?
- OOPs Concepts In C++ With Examples
- The Class OOPs Concept In C++
- The Object OOPs Concept In C++
- The Inheritance OOPs Concept In C++
- Polymorphism OOPs Concept In C++
- Abstraction OOPs Concept In C++
- Encapsulation OOPs Concept In C++
- Other Features Of OOPs In C++
- Benefits Of OOP In C++ Over Procedural-Oriented Programming
- Disadvantages Of OOPS Concept In C++
- Why Is C++ A Partial OOP Language?
- Conclusion
- Frequently Asked Questions
- Introduction To Abstraction In C++
- Types Of Abstraction In C++
- What Is Data Abstraction In C++?
- Understanding Data Abstraction In C++ Using Real Life Example
- Ways Of Achieving Data Abstraction In C++
- What Is An Abstract Class?
- Advantages Of Data Abstraction In C++
- Use Cases Of Data Abstraction In C++
- Encapsulation Vs. Abstraction In C++
- Conclusion
- Frequently Asked Questions
- What Is Encapsulation In C++?
- How Does Encapsulation Work In C++?
- Types Of Encapsulation In C++
- Why Do We Need Encapsulation In C++?
- Implementation Of Encapsulation In C++
- Access Specifiers & Encapsulation In C++
- Role Of Access Specifiers In Encapsulation In C++
- Member Functions & Encapsulation In C++
- Data Hiding & Encapsulation In C++
- Features Of Encapsulation In C++
- Advantages & Disadvantages Of Encapsulation In C++
- Difference Between Abstraction and Encapsulation In C++
- Conclusion
- Frequently Asked Questions
- What Is Inheritance In C++?
- What Are Child And Parent Classes?
- Syntax And Structure Of Inheritance In C++
- Implementing Inheritance In C++
- Importance Of Inheritance In C++
- Types Of Inheritance In C++
- Visibility Modes Of Inheritance In C++
- Access Modifiers & Inheritance In C++
- How To Make A Private Member Inheritable?
- Member Function Overriding In Inheritance In C++
- The Diamond Problem | Inheritance In C++ & Ambiguity
- Ways To Avoid Ambiguity Inheritance In C++
- Why & When To Use Inheritance In C++?
- Advantages Of Inheritance In C++
- The Disadvantages Of Inheritance In C++
- Conclusion
- Frequently Asked Questions
- What Is Hybrid Inheritance In C++?
- Importance Of Hybrid Inheritance In Object Oriented Programming
- Example Of Hybrid Inheritance In C++: Using Single and Multiple Inheritance
- Example Of Hybrid Inheritance In C++: Using Multilevel and Hierarchical Inheritance
- Real-World Applications Of Hybrid Inheritance In C++
- Conclusion
- Frequently Asked Questions
- What Is Multiple Inheritance In C++?
- Examples Of Multiple Inheritance In C++
- Ambiguity Problem In Multiple Inheritance In C++
- Ambiguity Resolution In Multiple Inheritance In C++
- The Diamond Problem In Multiple Inheritance In C++
- Visibility Modes In Multiple Inheritance In C++
- Advantages & Disadvantages Of Multiple Inheritance In C++
- Multiple Inheritance Vs. Multilevel Inheritance In C++
- Conclusion
- Frequently Asked Questions
- What Is Multilevel Inheritance In C++?
- Block Diagram For Multilevel Inheritance In C++
- Multilevel Inheritance In C++ Example
- Constructor & Multilevel Inheritance In C++
- Use Cases Of Multilevel Inheritance In C++
- Multiple Vs Multilevel Inheritance In C++
- Advantages & Disadvantages Of Multilevel Inheritance In C++
- Conclusion
- Frequently Asked Questions
- What Is Hierarchical Inheritance In C++?
- Example 1: Hierarchical Inheritance In C++
- Example 2: Hierarchical Inheritance In C++
- Impact of Visibility Modes In Hierarchical Inheritance In C++
- Advantages And Disadvantages Of Hierarchical Inheritance In C++
- Use Cases Of Hierarchical Inheritance In C++
- Conclusion
- Frequently Asked Questions
- What Are Access Specifiers In C++?
- Types Of Access Specifiers In C++
- Public Access Specifiers In C++
- Private Access Specifier In C++
- Protected Access Specifier In C++
- The Need For Access Specifiers In C++
- Combined Example For All Access Specifiers In C++
- Best Practices For Using Access Specifiers In C++
- Why Can't Private Members Be Accessed From Outside A Class?
- Conclusion
- Frequently Asked Questions
- What Is The Diamond Problem In C++?
- Example Of The Diamond Problem In C++
- Resolution Of The Diamond Problem In C++
- Virtual Inheritance To Resolve Diamond Problem In C++
- Scope Resolution Operator To Resolve Diamond Problem In C++
- Conclusion
- Frequently Asked Questions
C++ String Concatenation | All Methods Explained (With Examples)
The string is one of the most important topics in C++ programming language. In simple terms, a string is nothing but a collection of characters, and we use them for many purposes. For example, whenever we have to use an integer value that is out of bounds, we use a string to make it happen. In this article, we will discuss one of the most important operations on strings, i.e., C++ string concatenation. We'll discuss this string operation, how to perform concatenation and more.
Before we proceed, there are a few things one must note about strings. First, a string is very similar to an array, and we can traverse each character of a string just like array traversal. It should be noted that string in C++ is not a built-in data type but a custom one.
What Is String Concatenation In C++?
In simple terms, concatenation means linking things together in a series or merging things (here, input strings) together in a series. In other words, in C++, concatenation of strings means adding strings together to form another new/ single string.
Let's understand this with an example. Suppose we have two strings- one is “Being,” and the other is “Unstoppable,” and we want to concatenate them. Then the concatenated string will be “Being Unstoppable”

To learn all about the history and timeline of this language read- History Of C++ | Detailed Explanation (With Timeline Infographic)
How To Concatenate Two Strings In C++ Using The ‘+' Operator?
Now that we know what C++ string concatenation is and have seen an example, let's discuss the ways in which we can implement this in code. The first way that we will look at is- the concatenation of string using the ‘+’ operator.
Note that this is different from what we use in arithmetic operations. Because in arithmetic operations, the ‘+’ operator is used to add to numbers. But in the case of concatenation, the '+' operator is used to link two strings together. We have given two code snippets below; the first one of these shows the use of '+' as an arithmetic operator. And the second code snippet shows the use of the '+' operator for the concatenation of strings in C++.
Code example showing implementation of the '+' arithmetic operator:
#include
using namespace std;
int main()
{
int a=5,b=6;
cout <<a+b<<endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKCnsKCmludCBhPTUsYj02OwoKY291dCA8PGErYjw8ZW5kbDsKCn0=
Output: 11
Explanation: The '+' operator is used to get the addition of two numbers, a and b. But in strings, it is totally different.
Example: “5” +”6” !=”11”
In strings, if we use the ‘+’ operator, then it will give us a new string made from the two strings that we are concatenating.
Code example showing implementation of the '+' operator for concatenation of strings:
#include
using namespace std;
int main()
{
string str1="Be";
string str2="Unstoppable";
cout <<"New String after concatenating: "<<str1+str2<<endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKCnsKCnN0cmluZyBzdHIxPSJCZSI7CgpzdHJpbmcgc3RyMj0iVW5zdG9wcGFibGUiOwoKY291dCA8PCJOZXcgU3RyaW5nIGFmdGVyIGNvbmNhdGVuYXRpbmc6ICI8PHN0cjErc3RyMjw8ZW5kbDsKCn0=
Output:
New String after concatenating: BeUnstoppable
Explanation: When we used the ‘+’ operator on strings str1 and str2, it gives us a new string, “BeUnstoppable”.
Check this out- Boosting Career Opportunities For Engineers Through E-School Competitions
String Concatenation Using The strcat( ) Function
In C++, there is an inbuilt method for concatenating the strings, which is the strcat() function. This might seem similar to the append() fn, but there are key differences we must know. For example, in the strcat() fn, the destination string must be a pointer to a character array containing a C++ string. This is because it works for C-style strings only, that is, character arrays (str[]=”Unstoppable”). It cannot be used on C++ strings (str=”Unstoppable”).
Code Example:
#include <bits/stdc++.h>
using namespace std;
int main()
{
char str1[] = "You are ";
char str2[]= "Unstoppable";
strcat(str1, str2);
cout <<"New String after concatenating: "<<str1<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQoKewoKY2hhciBzdHIxW10gPSAiWW91IGFyZSAiOwoKY2hhciBzdHIyW109ICJVbnN0b3BwYWJsZSI7CgpzdHJjYXQoc3RyMSwgc3RyMik7Cgpjb3V0IDw8Ik5ldyBTdHJpbmcgYWZ0ZXIgY29uY2F0ZW5hdGluZzogIjw8c3RyMTw8ZW5kbDsKCnJldHVybiAwOwoKfQ==
Output:
New String after concatenating: You are Unstoppable
Explanation: In the above code, there are two strings of C type (character arrays), i.e., str1 and str2. We have passed these two strings into the strcat() function strcat(str1,str2), and it will give us a new string- You are Unstoppable
Note: The time complexity of the strcat() function is O(l1+l2), where l1 and l2 are the lengths of the strings.
Concatenation Of Two Strings In C++ Using Loops
For beginners and others who do not have an understanding of the strcat() function, another method for concatenating the strings is the use of a simple loop (like for loop or a while loop). In this section, we will discuss how to use both these types of loops to concatenate two strings in C++.
Also, note that we can both traverse strings and concatenate them with the use of loops.
1. C++ Program to Concatenate Two Strings Using The 'for Loop'
The below code shows us how to concatenate two strings using the for loop. In this case, we will be using two for loops to concatenate the two strings. The first for loop will be used for the traversal of the first string and store every character of it inside a third-string variable. Similarly, we will do this for the second string, and the resultant third string will be our concatenated string.
Example program C++:
#include <bits/stdc++.h>
using namespace std;
int main()
{
// declaring string variables
string str1="Learn with ",
str2="Unstop";
string str3;
for ( int i = 0; i < str1.size(); i++)
{
// adding character of the str1 into str3
str3 = str3 + str1[i];
}
for ( int i = 0; i < str2.size(); i++)
{
// adding character of the str1 into str3
str3 = str3 + str2[i];
}
cout <<"New String after concatenating: "<<str3<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQoKewoKLy8gZGVjbGFyaW5nIHN0cmluZyB2YXJpYWJsZXMKCnN0cmluZyBzdHIxPSJMZWFybiB3aXRoICIsCgpzdHIyPSJVbnN0b3AiOwoKc3RyaW5nIHN0cjM7CgoKCgoKCgpmb3IgKCBpbnQgaSA9IDA7IGkgPCBzdHIxLnNpemUoKTsgaSsrKQoKewoKLy8gYWRkaW5nIGNoYXJhY3RlciBvZiB0aGUgc3RyMSBpbnRvIHN0cjMKCgoKCnN0cjMgPSBzdHIzICsgc3RyMVtpXTsKCn0KCgoKCmZvciAoIGludCBpID0gMDsgaSA8IHN0cjIuc2l6ZSgpOyBpKyspCgp7CgovLyBhZGRpbmcgY2hhcmFjdGVyIG9mIHRoZSBzdHIxIGludG8gc3RyMwoKCgoKc3RyMyA9IHN0cjMgKyBzdHIyW2ldOwoKfQoKCgoKY291dCA8PCJOZXcgU3RyaW5nIGFmdGVyIGNvbmNhdGVuYXRpbmc6ICI8PHN0cjM8PGVuZGw7CgpyZXR1cm4gMDsKCn0=
Output:
New String after concatenating: Learn with Unstop
Explanation:
In the above example, we have taken two strings, str1 and str2, and another empty string str3. Using the first for loop, we added each character of str1 to str3, and using the second for loop, we added each character of str2 to str3, which is our final string.
Note- str1.size() function tells us the size of the string.
2. C++ Program to Concatenate Two Strings Using a while Loop
The code below shows us how to concatenate two strings using a while loop. To concatenate the two strings, we will be using two while loops. The first while loop will be used for the traversal of the first string and to get the first empty index. After that, we will use another while loop to add every character of the second string to the first string if it is not null. After adding the first string will get our result, i.e., a concatenated new string.
Example:
#include <bits/stdc++.h>
using namespace std;
int main()
{
char str1[]="You are ", str2[]="Unstoppable";
int i=0, j=0;
while(str1[i] != '\0')
{
i++;
}
while(str2[j] != '\0')
{
str1[i] = str2[j];
i++;
j++;
}
str1[i] = '\0';
cout <<"New String after concatenating: "<<str1<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQoKewoKY2hhciBzdHIxW109IllvdSBhcmUgIiwgc3RyMltdPSJVbnN0b3BwYWJsZSI7CgppbnQgaT0wLCBqPTA7CgoKCgp3aGlsZShzdHIxW2ldICE9ICdcMCcpCgp7CgppKys7Cgp9CgoKCgp3aGlsZShzdHIyW2pdICE9ICdcMCcpCgp7CgpzdHIxW2ldID0gc3RyMltqXTsKCmkrKzsKCmorKzsKCn0KCgoKCnN0cjFbaV0gPSAnXDAnOwoKY291dCA8PCJOZXcgU3RyaW5nIGFmdGVyIGNvbmNhdGVuYXRpbmc6ICI8PHN0cjE8PGVuZGw7CgpyZXR1cm4gMDsKCn0=
Output:
New String after concatenating: Learn with Unstop
Explanation:
In the above code, we have used two loops for string concatenation, one for iterating the first string and for adding the character of the second string to the first string.
String Concatenation Using The append() Function
There is another inbuilt function in C++ to concatenate the two strings, i.e., the append function. Using the in-built append method, we can add a string to another string, and when we print the first string, we will get the concatenated string. Let's look at an implementation program to get a better understanding of how to use this function to concatenate strings in C++.
Example:
#include <bits/stdc++.h>
using namespace std;
int main()
{
string str1="You are ", str2="Unstoppable";
str1.append(str2);
cout <<"New String after concatenating: "<<str1<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKQoKewoKc3RyaW5nIHN0cjE9IllvdSBhcmUgIiwgc3RyMj0iVW5zdG9wcGFibGUiOwoKCgoKc3RyMS5hcHBlbmQoc3RyMik7Cgpjb3V0IDw8Ik5ldyBTdHJpbmcgYWZ0ZXIgY29uY2F0ZW5hdGluZzogIjw8c3RyMTw8ZW5kbDsKCnJldHVybiAwOwoKfQ==
Output:
New String after concatenating: Learn with Unstop
Explanation-: In the above program, we have taken two strings and concatenated them using the append() function. If we concatenated str1 to str2, then to get the final result, we must print str1 and vice versa.
C++ String Concatenation Using The Inheritance Of Class
Inheritance is the concept of object-oriented programming. It is a process in which a new class (derived class) is created from an existing class (base class). And we can use this inheritance feature to concatenate two strings in C++. Below is a code example to showcase how this can be done.
Example:
#include <bits/stdc++.h>
using namespace std;
class unstop
{
protected:
virtual string concatenate(string &str1, string &str2) = 0;
};
class unstoppble: protected unstop {
public:
string concatenate (string &str1, string &str2) {
string str3;
str3 = str1 + str2;
return str3;
}
};
int main()
{
string str1="You are "
, str2="Unstoppble";
unstoppble obj;
cout <<"New String after concatenating: " << obj.concatenate (str1, str2)<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgdW5zdG9wCgp7Cgpwcm90ZWN0ZWQ6Cgp2aXJ0dWFsIHN0cmluZyBjb25jYXRlbmF0ZShzdHJpbmcgJnN0cjEsIHN0cmluZyAmc3RyMikgPSAwOwoKfTsKCmNsYXNzIHVuc3RvcHBibGU6IHByb3RlY3RlZCB1bnN0b3AgewoKcHVibGljOgoKc3RyaW5nIGNvbmNhdGVuYXRlIChzdHJpbmcgJnN0cjEsIHN0cmluZyAmc3RyMikgewoKc3RyaW5nIHN0cjM7CgpzdHIzID0gc3RyMSArIHN0cjI7CgpyZXR1cm4gc3RyMzsKCn0KCn07CgppbnQgbWFpbigpCgp7CgoKCgpzdHJpbmcgc3RyMT0iWW91IGFyZSAiCgosIHN0cjI9IlVuc3RvcHBibGUiOwoKdW5zdG9wcGJsZSBvYmo7Cgpjb3V0IDw8Ik5ldyBTdHJpbmcgYWZ0ZXIgY29uY2F0ZW5hdGluZzogIiA8PCBvYmouY29uY2F0ZW5hdGUgKHN0cjEsIHN0cjIpPDxlbmRsOwoKcmV0dXJuIDA7Cgp9
Output:
New String after concatenating: Learn with Unstop
Explanation-: In the above example, we have created one base class, ‘unstop’, which has a virtual function for concatenating the two strings. In the derived class ‘unstoppable’, we have taken a third variable str3, to store the concatenated string. When we create an object from a derived class in the main function, it gives us a concatenated string.
Concatenate Two Strings In C++ With The Friend and strcat() Functions
Apart from the methods we shared above, there are other ways to concatenate two strings in C++. This includes the use of the friend function and the strcat() function.
Example:
#include <bits/stdc++.h>
using namespace std;
class unstop {
public:
char str1[100]="Your are ", str2[100]="unstoppable";
friend void myfun(unstop b);
};
void myfun (unstop obj)
{
strcat (obj.str1, obj.str2);
cout <<"New String after concatenating: " <<obj.str1;
}
int main()
{
unstop obj;
myfun(obj);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgdW5zdG9wIHsKCnB1YmxpYzoKCmNoYXIgc3RyMVsxMDBdPSJZb3VyIGFyZSAiLCBzdHIyWzEwMF09InVuc3RvcHBhYmxlIjsKCmZyaWVuZCB2b2lkIG15ZnVuKHVuc3RvcCBiKTsKCn07Cgp2b2lkIG15ZnVuICh1bnN0b3Agb2JqKQoKewoKc3RyY2F0IChvYmouc3RyMSwgb2JqLnN0cjIpOwoKY291dCA8PCJOZXcgU3RyaW5nIGFmdGVyIGNvbmNhdGVuYXRpbmc6ICIgPDxvYmouc3RyMTsKCn0KCmludCBtYWluKCkKCnsKCnVuc3RvcCBvYmo7CgpteWZ1bihvYmopOwoKcmV0dXJuIDA7Cgp9
Output:
New String after concatenating: Learn with Unstop
Explanation:
In the above example, ‘unstop’ is a class that represents a string of characters. The myfun function concatenates two string objects by using the strcat() function, which appends the characters of one string to the end of another string.
Why Do We Need To Concatenate Two Strings?
Concatenating strings is one of the most important operations in strings in many programming languages, including Java, Python, C++, and JavaScript. It is widely used for applications such as web development, data processing, and text analysis. But do you know why we need to conduct this operation? Well, below are some other reasons why we should concatenate strings:
- Cross-Language Compatibility: String concatenation is a concept that is used in every programming language. It means if we understand it, we can apply this to any programming language. It is very useful when we working on a project which requires the use of two or more languages.
- Efficient Memory Usage: String in any programming language cannot be altered after we create them. And if we modify or append the string, then a new string object will be created. Now, if it is done repeatedly, it will cause inefficient memory use. On the other hand, if we use string concatenation, we can create a new string by combining existing strings, which is much more memory-efficient.
- Building Dynamic Strings: Concatenating strings allows us to create dynamic strings by combining different pieces of text or data at runtime.
- Formatting Data: String concatenation is often used to format data for display or storage purposes. For example, when logging data or generating reports, we may need to concatenate different pieces of data together, such as dates, times, numbers, or other values, to create a formatted output.
Let's take a look at another simple example of C++ string concatenation:
Suppose we want to print the name of every person in a family. The surname of every person will be the same. Let's suppose the surname is “xyz”.
Note that if we use string concatenation, we don't have to type surname every time.
#include <bits/stdc++.h>
using namespace std;
int main()
{
string surname="xyz";
cout<<"Amit " + surname<<endl;
cout<<"Rohit " + surname<<endl;
cout<<"Hema " + surname<<endl;
cout<<"Shruti " + surname<<endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKCgoKaW50IG1haW4oKQoKewoKc3RyaW5nIHN1cm5hbWU9Inh5eiI7Cgpjb3V0PDwiQW1pdCAiICsgc3VybmFtZTw8ZW5kbDsKCmNvdXQ8PCJSb2hpdCAiICsgc3VybmFtZTw8ZW5kbDsKCmNvdXQ8PCJIZW1hICIgKyBzdXJuYW1lPDxlbmRsOwoKY291dDw8IlNocnV0aSAiICsgc3VybmFtZTw8ZW5kbDsKCnJldHVybiAwOwoKfQ==
Output:
Amit xyz
Rohit xyz
Hema xyz
Shruti xyz
Explanation: We can define only one variable for the surname and can use it multiple times.
How To Reverse Concatenation Of Strings In C++?

We have seen many ways to concatenate strings in C++. Now we will see how to reverse the concatenation of string. Reverse concatenation means if a string of multiple words is given, we print individually every word of it.
Example: “You are unstoppable”
You
are
unstoppable
There is an inbuilt function for reverse concatenation in C++ that is strtok() function. It should be noted that it only works for C-style strings.
#include <bits/stdc++.h>
using namespace std;
int main ()
{
char str[] ="You are Unstoppable";
cout<<"String Before Reverse Concatenation: "<<str<<endl;
char * ptr;
ptr = strtok (str," ,.-");
cout<<"String After Reverse Concatenation: "<<endl;
while (ptr != NULL)
{
cout<<ptr<<endl;
ptr = strtok (NULL, " ,.-");
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKCgoKaW50IG1haW4gKCkKCnsKCmNoYXIgc3RyW10gPSJZb3UgYXJlIFVuc3RvcHBhYmxlIjsKCmNvdXQ8PCJTdHJpbmcgQmVmb3JlIFJldmVyc2UgQ29uY2F0ZW5hdGlvbjogIjw8c3RyPDxlbmRsOwoKY2hhciAqIHB0cjsKCnB0ciA9IHN0cnRvayAoc3RyLCIgLC4tIik7Cgpjb3V0PDwiU3RyaW5nIEFmdGVyIFJldmVyc2UgQ29uY2F0ZW5hdGlvbjogIjw8ZW5kbDsKCndoaWxlIChwdHIgIT0gTlVMTCkKCnsKCmNvdXQ8PHB0cjw8ZW5kbDsKCnB0ciA9IHN0cnRvayAoTlVMTCwgIiAsLi0iKTsKCn0KCnJldHVybiAwOwoKfQ==
Output:
String Before Reverse Concatenation: You are Unstoppable
String Before Reverse Concatenation:
You
are
Unstoppable
Explanation:
In the above code, we have taken a C-style string, and after using the strtok() function, the concatenated string will be broken into parts. While using the strtok() function, we have defined the character at which the string will break, that is, space(“ “), comma (,), full stop (.), and dash(-).
Conclusion
String concatenation is a very helpful tool in programming that allows us to efficiently manipulate strings, build dynamic strings, improve code readability and maintainability, achieve cross-language compatibility, and optimize performance. It is a fundamental concept that is widely used in various applications and programming languages. Understanding the benefits and proper usage of C++ string concatenation can greatly enhance our ability to work with strings and write efficient and effective code.
Frequently Asked Questions
Q. What is to_string in C++?
The to_string is an inbuilt function that is used to convert an integer value to a string value. For example-
int num=10;
// now value 10 will be a string.
string str= to_string(num);
Q. What is the fastest way to concatenate two strings?
There are many ways to concatenate strings in C++. But amongst all the methods available, the strcat() function is the fastest way to concatenate the strings. If we have passed two strings into the strcat function strcat(str1,str2) and it will give us a new string. The time complexity of the strcat() function is O(l1+l2), where l1 and l2 is the length of the strings.
Q. What operator is used to concatenate two strings?
In C++, the ‘+’ operator is used to concatenate two strings. In strings, if we use the ‘+’ operator, then it will give us a new string made from the two strings that we are concatenating.
“Be “ + “Unstoppable” = “Be Unstoppable”
Q. Can we concatenate two arrays in C++?
We cannot concatenate two arrays like strings, but there are other ways to merge the arrays. To merge the two arrays, we create another array and copy every element of the two arrays into the third array. The size of the third array should be equal to the sum of the size of two arrays that are getting merged.
The time complexity of this approach will be O(n1+n2), where n1 and n2 are the sizes of two arrays, and space complexity will also be O(n1+n2).
Q. How to concatenate two strings in C++ without using the strcat() function?
If we do not want to use the strcat() function for string concatenation, there are other methods. This includes the use of the append() function, using loops (for loop and while loop), and the ‘+’ operator and inheritance.
Q. How to split a string into 2 strings in C++?
If we want to split a string into strings into 2 strings, there is an inbuilt function for reverse concatenation in C++, which is the strtok() function. It should be noted that it only works for C-style strings. While using the strtok() function, we have defined the character at which the string will break, that is, space with quotes (“ “), comma (,), full stop (.), and dash(-).
Test Your Skills: Quiz Time
You might also be interested in reading the following:
- Typedef In C++ | Syntax, Application & How To Use It (With Examples)
- Find In Strings C++ | Examples To Find Substrings, Character & More!
- String Compare In C++ | Learn To Compare Strings With Examples
- Difference Between C And C++| Features | Application & More!
- 10 Best C++ IDEs That Developers Mention The Most!
An economics graduate with a passion for storytelling, I thrive on crafting content that blends creativity with technical insight. At Unstop, I create in-depth, SEO-driven content that simplifies complex tech topics and covers a wide array of subjects, all designed to inform, engage, and inspire our readers. My goal is to empower others to truly #BeUnstoppable through content that resonates. When I’m not writing, you’ll find me immersed in art, food, or lost in a good book—constantly drawing inspiration from the world around me.
Login to continue reading
And access exclusive content, personalized recommendations, and career-boosting opportunities.
Subscribe
to our newsletter
Comments
Add comment