Practical solutions

C++ Howtos How-To Guides

Solve the problem. Keep building. Collection of C++ how-to articles

Find the answer you need

Browse practical solutions, grouped by the task you're working on.

__COUNT__ entries on this page

How to Create, Access, and Print std::tuple Values in C++Learn to construct heterogeneous std::tuple values, access and update their elements, and print tuples of different sizes in C++. How to Loop Over an Array in C++This article provides a comprehensive guide on how to loop over an array in C++. Learn various methods including for loops, while loops, and range-based for loops with clear examples. Enhance your C++ programming skills by mastering these essential techniques for iterating through arrays. How to Calculate Distance Between Two Points in C++This article demonstrates how to calculate distance between two points in C++ How to Use the STL Queue Container in C++This article demonstrates how to utilize the STL queue container in C++. Void Pointer in C++Learn how C++ void* pointers hold object addresses, how to convert them to the correct pointer type before access, and which operations and uses are limited. How to Trim a String in C++Trim selected characters from the left, right, or both ends of a C++ string with find_first_not_of, find_last_not_of, and erase. How to Use setprecision in C++Learn how the C++ setprecision stream manipulator controls significant digits, how std::fixed sets decimal places, and how to align formatted values in columns. Class Redefinition in C++Understand and fix C++ class redefinition errors, then choose inheritance or composition to extend behavior. How to Use Callback Functions in C++This article demonstrates how to use callback functions in C++ How to Add Element to Vector of Pairs in C++This article demonstrates how to add an element to a vector of pairs in C++ How to Set the Precision of Floating-Point Numbers in C++This article demonstrates how to set the precision of floating-point numbers in C++ How to Create a File in C++Create or append to a file in C++ with standard streams or fopen, and check whether opening succeeded. C++ Get Variable TypeThe article includes two different methods to find the type of a variable in C++. One of the methods is to use the typeid operator whereas the other one is the decltype operator. How to Throw Out of Range Exception in C++This article discusses how to throw an out of range exception in C++. It covers methods for throwing and handling exceptions in C++, including using vectors and arrays. Learn about common errors and best practices to enhance your C++ programming skills. How to Check if Linked List Is Empty in C++This tutorial exemplifies how to check if a linked list is empty in C++. How to Capitalize First Letter of a String in C++Learn safe C++ approaches to capitalize a string's first character, first alphabetic character, or each word. How to Convert String to Int in C++This article explains how to convert a string to an integer in C++ How to Round a Double to an Int in C++This article demonstrates how to round a double to an int in C++. How to Reverse a String in C++This article introduces how to reverse a string in C++. Explore various methods including using the Standard Library, loops, and recursion. Each method is explained with clear code examples and detailed explanations to help you understand string manipulation in C++. Whether you're a beginner or an experienced coder, this guide is a valuable resource for enhancing your C++ skills. How to Handle SIGABRT Signal in C++Learn how SIGABRT behaves in C++ and how to install a POSIX handler with sigaction. How to Compare Arrays in C++Compare C++ arrays and ranges safely with loops, standard algorithms, byte comparison, and std::vector equality. C++ STL Binary SearchThis tutorial explains how to use `std::binary_search` from the C++ Standard Template Library. Learn its sorted-range requirements, explore examples, and apply custom comparators to user-defined types. How to Sort Vector in C++This article introduces how to sort vector in C++ Bubble Sort Algorithm in C++This article demonstrates how to implement bubble sort algorithm in C++