- 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++
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
1K+ Views
The strstr() function is a predefined function in string.h. It is used to find the occurance of a substring in a string. This process of matching stops at ‘\0’ and does not include it.Syntax of strstr() is as follows −char *strstr( const char *str1, const char *str2)In the above syntax, strstr() finds the first occurance of string str2 in the string str1. A program that implements strstr() is as follows −Example Live Demo#include #include using namespace std; int main() { char str1[] = "Apples are red"; char str2[] = "are"; char *ptr; ptr = strstr(str1, str2); if(ptr) cout
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
23K+ Views
A substring is a part of a string. A function to obtain a substring in C++ is substr(). This function contains two parameters: pos and len. The pos parameter specifies the start position of the substring and len denotes the number of characters in a substring.A program that obtains the substring in C++ is given as follows −Example Live Demo#include #include using namespace std; int main() { string str1 = "Apples are red"; string str2 = str1.substr(11, 3); string str3 = str1.substr(0, 6); cout
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
1K+ Views
Bitwise operators are used to perform bitwise operations. That implies the manipulation of bits. Some of the bitwise operators are bitwise AND, bitwise OR, bitwise XOR etc.A program to perform addition operation using bitwise operators is given below −Example Live Demo#include using namespace std; int main() { int num1, num2, carry; cout
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
408 Views
Random numbers can be generated in C++ using the rand() function. The srand() function seeds the random number generator that is used by rand().A program that uses rand() and srand() is given as follows −Example Live Demo#include #include #include using namespace std; int main() { srand(1); for(int i=0; i
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
1K+ Views
Lexicographical order denotes the way the words are ordered in a list, based on alphabetical order according to their alphabets. For example −List of words: Harry Adam Sam Lexicographical order of words: Adam Harry SamA program to sort elements in lexicographical order is as follows −Example Live Demo#include using namespace std; int main() { int i,j; string s[5], temp; cout
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
603 Views
Complex numbers are numbers that are expressed as a+bi where i is an imaginary number and a and b are real numbers. Some examples on complex numbers are −2+5i 3-9i 8+2iA program to add complex numbers by passing structure to a function is given as follows −Example Live Demo#include using namespace std; typedef struct complexNumber { float real; float imag; }; complexNumber addCN(complexNumber num1, complexNumber num2) { complexNumber temp; temp.real = num1.real + num2.real; temp.imag = num1.imag + num2.imag; return(temp); } int main() { complexNumber num1, num2, sum; cout num1.real; ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
581 Views
A structure is a collection of items of different data types. It is very useful in creating complex data structures with different data type records. A structure is defined with the struct keyword.An example of a structure is as follows −struct DistanceFI { int feet; int inch; };The above structure defines a distance in the form of feet and inches.A program to add two distances in inch-feet using a structure in C++ is given as follows −Example Live Demo#include using namespace std; struct DistanceFI { int feet; int inch; }; int main() { struct DistanceFI distance1, distance2, distance3; cout
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
812 Views
A vector is a dynamic array that can resize itself if an element is inserted or deleted. The vector elements are contained in a contiguous storage and the container handles the storage automatically.A program that implements vectors is given as follows −Example#include #include #include #include using namespace std; int main() { int ch, val; vector vec; cout
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
6K+ Views
Variable length arrays can have a size as required by the user i.e they can have a variable size.A program to implement variable length arrays in C++ is given as follows −Example Live Demo#include #include using namespace std; int main() { int *array, size; cout
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
4K+ Views
A parallel array is a structure that contains multiple arrays. Each of these arrays are of the same size and the array elements are related to each other. All the elements in a parallel array represent a common entity.An example of parallel arrays is as follows −employee_name = { Harry, Sally, Mark, Frank, Judy } employee_salary = {10000, 5000, 20000, 12000, 5000}In the above example, the name and salary of 5 different employees is stored in 2 arrays.A program that demonstrates parallel arrays is given as follows −Example#include #include using namespace std; int main() { int ... Read More