- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7346 Articles for C++
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
409 Views
Here we will see how to convert some enum type data to a string in C++. There is no such direct function to do so. But we can create our own function to convert enum to string.We shall create a function that takes an enum value as an argument, and we manually return the enum names as a string from that function.Example Code Live Demo#include using namespace std; enum Animal {Tiger, Elephant, Bat, Dog, Cat, Mouse}; string enum_to_string(Animal type) { switch(type) { case Tiger: return "Tiger"; case ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
1K+ Views
In this section, we will see how to convert C++ string (std::string) to const char* or char*. These formats are C style strings. We have a function called c_str(). This will help us to do the task. It returns a pointer to an array that contains a null-terminated sequence of characters (i.e., a C-string) representing the current value of the string object.Following is the declaration for std::string::c_str.const char* c_str() const;This function returns a pointer to an array that contains a null-terminated sequence of characters (i.e., a C-string) representing the current value of the string object. If an exception is thrown, ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
3K+ 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?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 found for character s and t, ... Read More
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
709 Views
In this section we will see what are the differences between string and the char[] in C++. The char[] is basically an array of characters. So there are some properties of this array. These properties are listed below.If the char[] is allocated in the stack section then it will always occupy 256 bytes of space. It will not depend on the size of the text.If we use malloc() or calloc() to dynamically allocate space for it into the heap section then we are responsible for releasing the memory after using this, and we always have the overhead of a heap ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
486 Views
This is another string matching method. In this approach, we are searching for a substring using vectors.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: “ABAAABCDBBABCDDEBCABC”, Pattern ... Read More
![Jennifer Nicholas](https://www.tutorialspoint.com/assets/profiles/13569/profile/60_88876-1512715262.jpg)
1K+ 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
![Nitya Raut](https://www.tutorialspoint.com/assets/profiles/13573/profile/60_92249-1512715559.jpg)
794 Views
Negate function is used to negate the given values such that to change the sign of the values. It changes the negative values to positive and vice-versa.Function prototype:function transform(a_begin, a_end, a1_begin, negate()): a_begin = lower bound of the array. a_end = upper bound of the array. a1_end = Lower bound of the second modified array. negate() = to negate the values of the array.Example Code#include #include #include using namespace std; int main() { int a[] = { 4,6,7, -10, -20, -30 }; transform(a, a + 6, a, negate()); for (int i = 0; i < 6; i++) cout
![Vrundesha Joshi](https://www.tutorialspoint.com/assets/profiles/13566/profile/60_88163-1512715024.jpg)
150 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
![Jennifer Nicholas](https://www.tutorialspoint.com/assets/profiles/13569/profile/60_88876-1512715262.jpg)
86 Views
lldiv() function in C++ STL gives the result of quotient and remainder of the division of the two numbers.AlgorithmBegin Take two long type numbers as input. Call function lldiv(). Print the quotient and remainder. End.Example Code#include #include using namespace std; int main() { long long q = 500LL; long long r = 25LL; lldiv_t res = lldiv(q, r); cout
![Nitya Raut](https://www.tutorialspoint.com/assets/profiles/13573/profile/60_92249-1512715559.jpg)
83 Views
iswalpha() function in C++ STL is used to check whether the given wide character is an alphabet or not.AlgorithmBegin Initializes the strings. Call function iswalpha(str) to check whether it contains alphabet or not. If it contains alphabet, then value will be returned otherwise zero will be returned. EndExample Code#include #include #include #include using namespace std; int main() { setlocale(LC_ALL, "ab1234"); wchar_t s[] = L"a%$^^&)"; bool flag = 0; for (int i=0; i