Found 7197 Articles for C++

Convert number string to integers in C++

Farhan Muhamed
Updated on 18-Apr-2025 19:02:00

392 Views

There are several inbuilt functions and objects to convert a number string to an integer in C++. Every method has its own advantages and disadvantages. In this article, we will discuss all the approaches to convert a number string to an integer in C++ with example code and use cases. Number String to Integer Conversion Here is the list of approaches to convert a number string to an integer in C++, which we will be discussing in this article with stepwise explanation and complete example codes. Convert Using stoi() Function ... Read More

Convert an integer to a hex string in C++

Farhan Muhamed
Updated on 17-Apr-2025 18:33:36

22K+ Views

Hexadecimal is a base 16 numbering system that uses 16 digits (from 0 to 9, and then A to F) to represent numbers. It is commonly used in computing systems to represent and store data. In this article, we will learn how to convert a normal integer to a hexadecimal string using C++ program. Integer to Hex String Conversion Here is a list of approaches for converting an integer to a hexadecimal, which we will be discussing in this article with stepwise explanation and complete example codes. Using std::stringstream ... Read More

Check if a string contains a sub-string in C++

Farhan Muhamed
Updated on 17-Apr-2025 18:56:43

8K+ Views

A substring is a continues sequence of characters within a larger string. For example, the string "point" a substring of the string "TutorialsPoint". In this article, we will learn different approaches to check if a string contains a substring in C++. Here is a list of approaches for checking if a string contains a substring, which we will be discussing in this article with stepwise explanation and complete example codes. Using find() Using search() Using regex_search() Manual Substring ... Read More

Case-insensitive string comparison in C++

Farhan Muhamed
Updated on 17-Apr-2025 19:24:48

9K+ Views

To compare two strings in C++, we can use various inbuilt functions and approaches that are already discussed in the previous sections. However, there are some cases where we need to compare two strings case-insensitively, meaning that we need to ignore the case of the characters in the strings while comparing them. In this article, we will focus on learning how to compare two strings case-insensitively in C++. Here is a list of approaches for case-insensitively string comparison, which we will be discussing in this article with stepwise explanation and complete example codes. ... Read More

C++ Program to Perform String Matching Using String Library

Farhan Muhamed
Updated on 26-May-2025 12:47:32

3K+ Views

The string library provides several functions to manipulate and match strings. In this article, we will see how the various functions of string library functions can be used to match strings in C++. String Matching in C++ String matching is a process of locating one string in another string. Meaning, here we will find the position of a string inside another string. The string matching functions will return the position of the first occurrence of the substring in the main string. If the substring is not found, it will return a special value such as -1 or string::npos. ... Read More

C++ Program to Implement Wagner and Fisher Algorithm for online String Matching

Farhan Muhamed
Updated on 22-May-2025 18:06:15

478 Views

Here, we will see how to use Wagner and Fisher algorithm for string matching in C++. Using this algorithm, we can find how many minimum changes are required to match those strings. Wagner Fisher Algorithm Wagner Fisher is a dynamic programming algorithm that is used to find the minimum edit distance or levenshtein distance between two input strings. Levenshtein distance between two strings means the number of changes (ie, insertion, deletion or updation) required to convert one string into another. In simpler words, this algorithm will calculate a minimum number of changes required to convert ... Read More

C/C++ Macro for string concatenation

Farhan Muhamed
Updated on 16-Apr-2025 19:01:53

5K+ Views

C++ provides multiple ways to concatenate strings. Macro string concatenation is one of such way. In this article, we will learn how to use C++ preprocessor macros to concatenate strings and tokens. Understanding Macros in C++ In C++, macros are small pieces of code that are defined using the preprocessor directive #define. Macros are generally used to define variables, constants, functions, and other code blocks. When the code is compiled, the preprocessor replaces every occurrence of the macro with its defined value before actual compilation begins. Let's see an example of a macro definition and its usage. // ... Read More

C++ Program to Check the Connectivity of Undirected Graph Using DFS

Jennifer Nicholas
Updated on 15-Apr-2025 18:12:55

4K+ Views

The Depth-First Search (DFS) is a graph traversal algorithm that starts at root node and explores as far as possible along each branch before moving to next branch. In this article, we will discuss how to check the connectivity of a graph using DFS traversal algorithm. Understanding Connectivity of a Graph A graph is said to be connected if there is a path between every pair of vertices. To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any node, which is not visited, then ... Read More

C++ Program to Check the Connectivity of Directed Graph Using BFS

Farhan Muhamed
Updated on 15-Apr-2025 18:14:46

812 Views

The Breadth-First Search (BFS) algorithm is a graph traversal algorithm that starts at the tree root and explores all nodes at the present depth before moving to the nodes at the next level. In this article, we will discuss how to check the connectivity of a directed graph using BFS traversal algorithm. Understanding Connectivity of a Graph A graph is said to be connected if there is a path between every pair of vertices. To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any ... Read More

C++ Program to Check the Connectivity of Undirected Graph Using BFS

Vrundesha Joshi
Updated on 15-Apr-2025 12:55:54

1K+ Views

The Breadth-First Search (BFS) algorithm is a graph traversal algorithm that starts at the tree root and explores all nodes at the present depth before moving to the nodes at the next level. In this article, we will discuss how to check the connectivity of a graph using BFS traversal algorithm. Understanding Connectivity of a Graph A graph is said to be connected if there is a path between every pair of vertices. To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any ... Read More

Advertisements