Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Articles - Page 630 of 719
928 Views
In this article, we will see how to convert a Decimal to a Hexadecimal string and versa in C++. For this conversion, we are using the string stream feature of C++. You can use StringStreams for formatting, parsing, converting a string into numeric values, and more. The Hex is an I/O manipulator. It takes a reference to an I/O stream as a parameter and returns a reference to the string after manipulating it. Implementation of converting Decimal to Hexadecimal In the following example, we will see how to convert decimal numbers or hexadecimal numbers in C++. #include #include ... Read More
3K+ Views
In this article we will see what are the Stringize operator and Token Pasting operator in C. The stringize operator (#) and the token pasting operator (##) are preprocessor operators used within macros for text manipulation. It sends commands to compiler to convert a token into string. Stringize Operator (#) The stringize operator (#) is a preprocessor operator that converts the micros parameter into a string literal. The preprocessor encloses the actual argument passed to the macro in double quotes, effectively convert it into a string. Syntax Following is the syntax of Stringize Operator: #define MACRO_NAME(arg) #arg ExampleIn ... Read More
661 Views
C provides libraries for string operations such as the string.h header file that contains a strlen() function, which counts the length of a string. Otherwise, a loop can be used to count the string length. There are also different ways to find the length of a string apart from the above two methods. So, basically, in this article, we will learn how to find the length of a string without string.h and loop in C. Find Length of a String Without string.h and Loop in C There are the following ways to find the string's length without using the string.h ... Read More
3K+ Views
std::string The std::string is a class of C++ Standard Library (STL) that represents a string (sequence of characters). It is used to handle strings with better memory management, i.e., it provides dynamic memory management for strings and supports a rich set of in-built functions for string manipulation. Syntax Following is the syntax of string: string str = "tutorialspoint"; std::LPCWSTR The LPCWSTR stands for Long Pointer to Constant Wide STRing. It is a constant string of 16-bit Unicode characters, which may be null-terminated. It is the same as a string but with wide characters. Syntax Following is the syntax of ... Read More
4K+ Views
std::string The std::string is a class of C++ Standard Library (STL) that represents a string (sequence of characters). It is used to handle strings with better memory management, i.e., it provides dynamic memory management for strings and supports a rich set of in-built functions for string manipulation. Syntax Following is the syntax of string: string str = "tutorialspoint"; std::LPCSTR LPCSTR stands for Long Pointer to Constant String. It is a constant, null-terminated string of ANSI (narrow) characters (8-bit characters). In contrast to LPCWSTR, which stores wide characters (Unicode/UTF-16), LPCSTR is used in Windows API functions to store regular char-based ... Read More
381 Views
A histogram is a visual representation of the distribution of quantitively data. You are given a histogram represented by an array arr [], Where each of the array's elements represents the height of the bar in the histogram. All the bars have unit width, i.e., 1 unit. Your task is to determine the largest rectangle area possible in a given histogram, where the largest rectangle is made up of several consecutive bars with heights displayed in an array. Input / Output Scenario Let's understand the below input-output scenario with a diagram: Input: arr[] = [40, 10, 20, 50, 60, 30] ... Read More
184 Views
Here is a C++ Program to implement First Fit Decreasing for 1-D objects and M binsRequired functions and pseudocode:Begin function binPack() returns number of bins required. Initialize binC = 0 Initialize an array to store binVal. Place items one by one. function sort() to perform bubble sort in the descending order. EndExample Code#include using namespace std; void binPack(int *a, int s, int n) { int binC = 0; int binVal[n]; for (int i = 0; i < n; i++) binVal[i] = s; for (int i = 0; i < ... Read More
4K+ Views
This is a C++ Program to Implement the Edmonds-Karp algorithm to calculate maximum flow between source and sink vertex.Algorithm:Begin function edmondsKarp() : initiate flow as 0. If there is an augmenting path from source to sink, add the path to flow. Return flow. EndExample Code#include #include #include #include #include using namespace std; int c[10][10]; int flowPassed[10][10]; vector g[10]; int parList[10]; int currentPathC[10]; int bfs(int sNode, int eNode)//breadth first search { memset(parList, -1, sizeof(parList)); memset(currentPathC, 0, sizeof(currentPathC)); queue q;//declare queue vector q.push(sNode); parList[sNode] = -1;//initialize parlist’s ... Read More
617 Views
This is a C++ Program to implement Network_Flow problem using Ford Fulkerson algorithm.Algorithms:Begin function bfs() returns true if there is path from source s to sink t in the residual graph which indicates additional possible flow in the graph. End Begin function fordfulkarson() return maximum flow in given graph: A) initiate flow as 0. B) If there is an augmenting path from source to sink, add the path to flow. C) Return flow. EndExample Code#include #include #include #include #define n 7 using namespace std; bool bfs(int g[n][n], int s, int ... Read More
3K+ Views
A Binary Search Tree is a sorted binary tree in which all the nodes will have following properties−The right sub-tree of a node has a key greater than to its parent node's key.The left sub-tree of a node has a key lesser than to its parent node's key.All key values are distinct.Each node cannot have more than two children.Class Descriptions:Begin class BST to declare following functions: search() = To search an item in BST. initialize temp = root; while(temp != NULL) Increase ... Read More