Found 7197 Articles for C++

Differences between C++ string == and compare()?

Farhan Muhamed
Updated on 26-May-2025 18:17:37

4K+ Views

In C++ we can compare two strings using compare() function and the == operator. Then the question is why there are two different methods? Is there any difference or not? Yes, there are some basic differences between compare() and == operator. In C++ the == operator is overloaded for the string to check whether both strings are same or not. If they are the same this will return 1, otherwise 0. So it is like Boolean type function. The compare() function returns two different things. If both are equal, it will return 0, If the mismatch is ... Read More

Difference between string and char[] types in C++

Farhan Muhamed
Updated on 26-May-2025 18:18:53

831 Views

In C++, char[] represents a character array, while string is a class in STL to manage text data. Both string and char[] can be used to store and process text data. But, they are different in terms of structure, usage, memory management, and capabilities. In this article, we will discuss the difference between string and char[] types in C++. char[] in C++ char[] is an array of characters that is used to store a string. It is a C-style string representation. The size of char array will be fixed. At the end of the array, a null character '\0' ... Read More

C++ Program to Implement String Matching Using Vectors

Farhan Muhamed
Updated on 04-Jun-2025 16:25:31

631 Views

In C++, we can create vectors easily using the standard library. We are taking the main string and the string that will be searched as a vector, then searching it into the main string. When one match is found the function returns the address, and removes it from the main string. So in the next iteration, it starts from location 0 and searches again. For multiple occurrences, we are using loops and repeatedly searching for the match, and return the position. Input: Main String: "ABCcdABCcdABC" Substring to search: "cd" Output: Match found at Position = 1 Match found at ... Read More

Wrapping C/C++ for Python using SWIG

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

2K+ Views

There are multiple ways to wrap your existing C or C++ functionality in Python. In this section, we are going to see how we can wrap C/C++ functionality with SWIG. Below are other options to wrap c/c++ functionality in python.Manual wrappingUsing pyrex to wrap C code.CtypesSIPBoost PythonSWIG (Simple Wrapper Interface Generator) is capable of wrapping C code with numerous other languages including Perl, Python, PHP, Ruby, Tcl, C#, Common Lisp (CLISP, Allegro, CL, UFFI, CFFI), Java, Modula-3 and OCAML. Swig also supports multiple interpreted and compiled Scheme implementations (like Guile, MzScheme, Chicken) are supported.But we will discuss its implementation with ... Read More

negate function in C++ STL

Farhan Muhamed
Updated on 15-May-2025 11:23:14

1K+ Views

The negate function in C++, is a function object (functor) that returns the negation of a the given value. In this article, we will learn how to use the negate function from the Standard Template Library (STL) in C++. What is negate? The negate function is a predefined function object defined in the STL that performs arithmetic negation. It takes a single value and returns its negative value. For example, if the input is 5, the output will be -5. This operation is useful when we want to apply negation inside STL algorithms like transform() or for_each() without writing ... Read More

multiset insert() function in C++ STL

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

232 Views

The multiset insert() function in C++ STL which insert elements in the multiset container from a position to another position from one multiset to a different multiset.List of functions used:ms.size() = Returns the size of multiset. ms.insert() = It is used to insert elements to the multiset.Example Code#include #include #include #include using namespace std; int main() {    multiset ms;    multiset::iterator it, it1;    int c, i;    while (1) {       cout

lldiv() function in C++ STL

Farhan Muhamed
Updated on 06-Jun-2025 18:56:54

153 Views

The lldiv() function is used to perform division operation on long long integers and return both quotient and remainder. In this article, we will learn how to use the lldiv() function from the Standard Template Library (STL) in C++. What is lldiv()? The lldiv() is a in-built function in C++ that is used to divide one long long integer by another and return the result as a structure that contains both the quotient and remainder. This function is useful when both values are needed after a division operation. The return type of this function is a structure called lldiv_t, ... Read More

iswalpha() function in C++ STL

Farhan Muhamed
Updated on 12-Aug-2025 17:16:47

231 Views

The iswalpha() function is an extension of the isalpha() function, which supports character identification of all languages. In this article, we will learn how to use the iswalpha() function from the Standard Template Library (STL) in C++. What is iswalpha()? The iswalpha() function is used to check whether a given wide character is an alphabetic character. Wide character means the larger set of characters, which includes the characters from all languages. The iswalpha() function returns true if the input character is a letter, such as from English, Hindi, Chinese, etc. The regular isalpha() function will only work with alphabets ... Read More

iswalnum() function in C++ STL

Farhan Muhamed
Updated on 13-May-2025 19:31:26

241 Views

The iswalnum() function is an extension of isalnum() function to support character identification of all languages. In this article, we will learn how to use the iswalnum() function from the Standard Template Library (STL) in C++. What is iswalnum()? The iswalnum() function is used to check whether a given wide character is alphanumeric. An alphanumeric character is either an alphabet letter (a-z, A-Z) or a digit (0-9). Wide character means, the larger set of characters, which include the characters from all the languages. The iswalnum() function returns true if the input character is either a letter from any language ... Read More

Insertion and Deletion in STL Set C++

Farhan Muhamed
Updated on 04-Jun-2025 18:48:48

1K+ Views

The STL set is a container that stores unique elements in a sorted order. Insertions and deletions are common operations performed in containers like std::set and std::vector. In this article, we will learn how to insert and delete elements in a C++ STL set. Insertion in STL Set To insert a new element into a std::set you can use the insert method or the emplace method. Let's understand how to use these methods with examples. Using insert Method Using emplace Method 1. Using insert Method The insert ... Read More

Advertisements