Click here to Skip to main content
15,889,116 members
Everything / Programming Languages / C++17

C++17

C++17

Great Reads

by Jovibor
Owner-draw list control with tooltips, editing, colors, sorting, hyperlinks, columns hiding and lot more.
by sebjameswml
morph::vvec allows you to do vector math without any external libraries
by Bartlomiej Filipek
What performance can we get from C++17 parallel algorithms?
by Mikhail Semenov
This article shows that double-ended vector is much faster than std::deque and should be preferred.

Latest Articles

by Shao Voon Wong
C++17 easy string to number and vice versa conversions in header-only class
by Michael Chourdakis
A set of tools to create a new VCXPROJ file automatically
by sebjameswml
morph::vvec allows you to do vector math without any external libraries
by Coral Kashri
CoreC++ talk - experience summarize, and self opinions

All Articles

Sort by Title

C++17 

9 Jan 2023 by honey the codewitch
A project that allows you to use a knob to control a fan's RPM with feedback
27 May 2021 by John M. Dlugosz
Using swap etc. from generic code must be done properly. Here’s how to fix it for good.
3 Aug 2021 by Stefan_Lang
We're developing plugins for a third party executable with a C++ API. There is no SDK available for the executable, and, worse, no debug version. The API uses at the very least std::vector and MFC CString which to my knowledge are not compatible...
1 Aug 2021 by KarstenK
In this cases I like to write a log file with the debug texts and some error messages. Best is to check the amount of written data in some debug tests and only log errors and problems. Normally the problematic code areas are knows so concentrate...
2 Aug 2021 by Greg Utas
Release builds have reached the point where the trade-off between performance and debugging is unacceptable. I'm using VS2017 and face the same problems. Here[^] are the compiler settings I use. They help, but it's still not as easy as a debug...
2 Aug 2021 by Rick York
When I have done this I disabled optimizations in the release build of the library and enabled writing of the debug symbols file. I then set the hosting executable program for debugging the library to be the one in question and then set break...
3 Aug 2021 by steveb
You can include debug information in the release build. It will behave as if it was debug build, i.e. stepping through code, breakpoints in code etc.
19 Sep 2020 by Daniel Petrovic
In this tip, I want to represent a quick lightweight possibility (one of many) for parsing command line arguments on the fly using C++17.
7 Jan 2018 by Michael Chourdakis
Reduce function recursion with variadic templates
13 Mar 2020 by Volynsky Alex
New features of the C++17 standard
17 Jan 2022 by Giuseppe Pischedda
Part 2 - Templates and variadic templates
14 Jan 2022 by Giuseppe Pischedda
How to create a Win32 C++ Application that "consumes" a C++/WinRT Component Runtime
27 Jan 2024 by Shao Voon Wong
C++17 easy string to number and vice versa conversions in header-only class
16 Jan 2020 by Shao Voon Wong
Benchmark of Singular Min/Max and Iterator Versions
24 May 2020 by Shao Voon Wong
How to allocate variable-size arrays on the Stack in C/C++
14 Dec 2021 by Ramandeep Singh Dec2021
```` // this is a code class Solution { public: ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { int carry = 0, first, second; ListNode *head = new ListNode(0), *tail = head; **while (l1 || l2 || carry)** { ...
14 Dec 2021 by OriginalGriff
You understand OR, I assume? a || b is true is either a, b, or both is true: it is only false if both a and b are both false. And in C (and so C++) any non-zero value is true, so any valid link in l1 or l2 or carry will mean the loop goes around...
3 Feb 2022 by Pratiksh Kumar
code not working properly. i used num1%num2. cases where rem =0, its printing again nd again 0. Please the code. What I have tried: #include using namespace std; int main() { int num1,num2; coutnum2 \n"; ...
3 Feb 2022 by M Imran Ansari
You are assigning in If block instead of checking the equality. Correct If condition if(num==0) { cout
3 Feb 2022 by Tony Hill
You are not testing num for 0 correctly. You should do if(num == 0) not if (num=0) In your code you are assigning 0 to num because you are using a single equals sign which will be successful which the if statement evaluates to...
6 Jun 2021 by Member 15231776
int length(ListNode* head){ int ct = 0; ListNode* temp = head; while(temp != NULL){ temp = temp->next; ct++; } return ct; } ListNode* reverse(ListNode* head){ ListNode*...
6 Jun 2021 by OriginalGriff
Compiling does not mean your code is right! :laugh: Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email...
20 Jan 2024 by Michael Chourdakis
A set of tools to create a new VCXPROJ file automatically
7 Jun 2021 by The Ænema
Learn how to convert any code to a stable shellcode using Visual Studio 2019 and VC++ in easy steps!
8 Dec 2021 by John M. Dlugosz
A simple pair of iterators provides many handy use cases
4 Oct 2023 by honey the codewitch
I've got a persistent warning across all the compilers I've tried. It has to do with the srf var in the "What have you tried" section. Basically the compiler doesn't know that srf can't be very big. Specifically, it is limited to the...
4 Oct 2023 by OriginalGriff
Have you tried ANDing it with 111111b? Since the value can't be bigger than 63 that might shut the compiler up?
2 Feb 2023 by Bruno van Dooren
Ways to enforce an interface contract on static methods, similar to what you would expect from static virtual methods if they'd exist in C++
31 Mar 2020 by Member 14162950
I am trying to build a C++ example program from the Phidgets company website that monitors and logs three devices. Using either VS2017 or VS2019 gives 20 lines of messages similar to this one: Log_Mul_Phids(C17_9).obj : error LNK2019: unresolved...
30 Mar 2020 by Maciej Los
Please, follow the instruction from MSDN: Linker Tools Error LNK2019 | Microsoft Docs[^]
31 Mar 2020 by steveb
Did you include the .LIB file in your linker input?
25 Oct 2021 by shadi zgheib
I keep receiving an error saying "Expression must have a constant value the value of variable 'n1' cannot be used as a constant ". I don't know what am I use suppose to do to fix it. void merge(DataType theArray[], int first, int mid, int last)...
25 Oct 2021 by Patrice T
void merge(DataType theArray[], int first, int mid, int last) // did you forgot the '{' here ? int i, j, k; int n1 = mid - first + 1; int n2 = last - mid; int L1[n1], R1[n2]; //n1, n2 are giving me the same problem mentioned above for (i =...
25 Oct 2021 by k5054
You don't say what compiler/OS you are using, but since this above snippet is accepted by gcc, I am guessing that you are using MSVC, which does not support variable length arrays. You will have to use dynamic memory allocation to create an...
10 Apr 2021 by honey the codewitch
I'm trying to invoke a template function from inside another template, and the C++ compiler is getting confused trying to parse my code. Basically what's happening is it can't tell that my function is a template function. It thinks it's a field,...
10 Apr 2021 by Greg Utas
This is fancier than anything I've done with templates, so I could be off base here. But recently there was a question involving the use of typename to explicitly flag a type within a template, and yours looks related to that, only a little...
5 Jan 2018 by Michael Chourdakis
The most appealing (to me!) new C++ features
20 Jun 2023 by Coral Kashri
CoreC++ talk - experience summarize, and self opinions
3 Jan 2020 by goranorsander
A class template for specializing fundamental types
3 Jun 2021 by honey the codewitch
Explore techniques for drawing using GFX
11 Apr 2021 by honey the codewitch
A device independent graphics library for IoT devices. Part 1 of a series.
17 Apr 2021 by honey the codewitch
GFX IoT graphics library part 2 - device independent bitmaps
25 Apr 2021 by honey the codewitch
Explore the basic drawing functionality provided by the GFX IoT library
4 May 2021 by honey the codewitch
Use an ILI9341 display efficiently from an ESP32 without the Arduino framework. Load JPEGs.
23 Jun 2018 by John M. Dlugosz
Using the new structured binding feature in your API design
6 May 2023 by Richard MacCutchan
Why not use the features provided: NtQueryInformationProcess function (winternl.h) - Win32 apps | Microsoft Learn[^] ?
7 May 2023 by WOLF 2018
So I have been working on learning the windows low end side of thing and I created some asm to access the peb without using any library's. This is because my project has /NODEFAULTLIB on and no inputs in Visual Studio So my project is about...
7 May 2023 by merano99
As Richard already pointed out, there are quite a few Windows system calls in the rest of the code and it would certainly be possible to get the pointer without assembler, but if you really want to, you can do it with VisualStudio and assembler. ...
26 Mar 2023 by Emily Wael
Mohamed has an array A with N element, Mohamed wants to know if there is three numbers that Ai * Aj
26 Mar 2023 by Rick York
Here is one place to start : cplusplus.com : fgets[^]. The sample code shows you how to open a file, read from it, and close it. That's what you need to do to read the data from the file. This function - cplusplus.com : atoi/[^], can be used...
26 Mar 2023 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
18 Nov 2021 by Hansen 2021
Sample Input 3 6 -4 2 -1 8 4 5 8 -1 82 33 14 -5 60 79 84 5 -4 -7 8 4 -11 Sample Output 1 2 3 Output is a smallest order different value What I have tried: #include int main(){ int C; int N; int n; scanf("%d", &C); for(int i =...
18 Nov 2021 by OriginalGriff
Firstly, there is no obvious connection between the input and the desired output - so go back to the original assignment, and read it carefully. Then try to process the input manually and generate the output - hwne you hav eit manually, it should...
18 Nov 2021 by KarstenK
You best start with some Learn C tutorial to learn the basic. Pay attentation how to use the debugger. Without the knowledge and skills to develop code you cant move on and will get a bad rating from your teacher. tip: also search on Youtube...
8 Jan 2022 by Sheeda Bro
I am storing Floor objects in Floor floor_arr[3] array. Then using this array to call Floor class display() function. The problem is available rooms are always 0 because of constructor. I guess the available rooms value is not being returned by...
8 Jan 2022 by KarstenK
You mismatching the objects. Writing "Clear code" with better names would help you to avoid such bugs. Change to: int main() { int floorInput, roomsInput; Hotel hotel; Floor floor; Use the debugger for further details.
8 Jan 2022 by Stefan_Lang
You are calling the display method on your Hotel object and that displays the Floors within that Hotel, but you never correctly initialized the Floor objects stored inside your Hotel object. Instead you created and initialized a separate Floor...
26 May 2019 by Member 14470453
I have created a project in Dev C++, but I need to create a window and control mouse events over a button. Could you help me please? What I have tried: I used next cod, but it do not works properly // Grafica de la circunferencia //#include #include #include ...
25 May 2019 by Maximilien
I don't know Dev C++ , but you need a GUI toolkit to create buttons. As far as I can see, you need to create a new project of type "Windows Application" and start coding Win32 UI elements. For example : How to Make Button in Dev C++ | C++ Tutorial - YouTube[^] Good luck.
26 May 2019 by Tonex247
Buttons are actually windows and are created same way: #define btn_ID 5000 //used as the button's id during creation HWND hwndButton = CreateWindowEx( 0, L"BUTTON", // Predefined class; Unicode assumed L"OK", // Button text WS_TABSTOP | WS_VISIBLE | WS_CHILD |...
26 May 2019 by CPallini
It looks your trying to use a port of the BGI library to Windows. Here you may find documentation and smple code: Borland Graphics Interface (BGI) Documentation[^].
24 Jan 2024 by Dave Kreskowiak
A better choice would be a Windows Service since they have no UI at all. Trying to do this as a normal, user launchable app seems ... suspicious.
24 Jan 2024 by Maxim Kartavenkov
You can create regular windows application not the console application, just do not create any dialogs and proceed like you do as you had the console application. There will be just linker configuration change and the function WinMain instead of...
24 Jan 2024 by k5054
It's not clear what you're trying to achieve. If you want to create a service, then you should follow the advice in Solution 1. If you're trying to create a commandline utility, like copy for example, then what you're doing is probably what you...
24 Jan 2024 by Eduardo Quintana
I need to create a C++ console program that executes without exhibiting a window of any kind. All processing should be done in the background without any screen drawing. What I have tried: I tried to hide the console window but it always...
30 Jan 2024 by steveb
Use a WinMain without the window creation
12 Aug 2021 by T Bones Jones
I am trying to parse a rather long string of csv values into a vector of doubles. Here is my string: 290, -44.71807341742762, -253.3983378443242, -2830.845102033997, -50.72846875682069, -244.9233159558827, -2828.886659819535, -27.65164366754831,...
12 Aug 2021 by Rick York
The reason it works is you were passing the separator by reference the first time and by value the second. It works when it is passed by value. What I do is if an item is not changed and is plain, old data (POD) then I always pass it by value. ...
11 Mar 2019 by Member 10068530
I want to consume c++17 modules from managed clr/c++ code. Is it possible? What I have tried: I have built a dll with c++ modules. Consumed it from a console application without turning /clr. Everything worked. Once i turn on /clr switch, it does not work. My clr console application has...
11 Mar 2019 by steveb
There are many ways you can do that: 1. Implement your C++ 17 as DLL and export "C" function interface. There are ton of material on google how to call DLLs from CLR or .Net langs. 2. Implement as COM DLL. This one can be called by any language VB, C#, C++, C etc 3. Implement as COM EXE server....
19 Oct 2022 by Death Smoke
I Want to convert the output of this code to string type , but i cant make it. #pragma warning(disable : 4996) #include int main() { char cmd[10]; strcpy(cmd, "dir"); system(cmd); } What I have tried: I tried to...
16 Oct 2022 by merano99
The command system() creates a new process to handle the specified command. char cmd[10]; strcpy(cmd, "dir"); system(cmd); In most cases, this is neither performant nor useful. But of course you can start a process with C this way. You could...
19 Oct 2022 by Alexandrnn
#include #include int main() { system("dir"); puts((char*)stdin); } #include #include #include int main() { char cmd[10]; strcpy_s(cmd, 10, "dir"); system(cmd); puts((char*)stdin); }
19 Oct 2022 by CPallini
Are you possibly searching for popen? See, for instance: The Marvelous popen() Function | C For Dummies Blog[^]
14 Mar 2023 by sebjameswml
Walks you through the steps needed to draw high quality 2D graphs in your C++ programs using the header-only library morphologica
27 Oct 2022 by Death Smoke
Hi all, I Searched how to delete a whole key from the Registry using c++ anyone here can help me because i didnt find any clear example about this subject. the key path is like here : Computer\HKEY_USERS\folder \folder\ folder\{Key name}. So...
20 Oct 2022 by Rick York
Have you investigated the RegDeleteKeyExA function (winreg.h) - Win32 apps | Microsoft Learn[^] ? Here is another sample : Deleting Registry Key with Subkeys Win32 C program example[^]
25 Oct 2022 by Michael Haephrati
In the code below you can see how to delete a subkey or the entiry key HKEY hKey = NULL; long lReturn = RegOpenKeyEx( HKEY_USERS. _T("folder \folder\ folder\{Key name}"), 0L, ...
19 Sep 2023 by sebjameswml
morph::vvec allows you to do vector math without any external libraries
26 Aug 2022 by Fatima Zahid 2022
how to write a program in c++ inwhich i have to define user defined data type variable name,car that store five attributes such as carnammodel,,vendor,ownerid with taking inputs from user for all attributes? What I have tried: I tried...
26 Aug 2022 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
26 Aug 2022 by Fatima Zahid 2022
// Project36,a car variable as userdefined datatype.cpp : This file contains the 'main' function. Program execution begins and ends there. #include #include #include using namespace std; char structurecar() { char a; int b; char...
20 Oct 2021 by rdeekonda
I am using an outlookbar style property sheet with 3 property pages as the main window of my application.I am unable to change the bitmap icons displayed on the property sheet.I have given code here which isn't working. Please suggest any...
20 Oct 2021 by KarstenK
The MS controls are creating an own copy of the bitmaps. So when you want to change them, you need to destroy the control and recreate a new object with the new bitmaps.
20 Oct 2021 by Rick York
Yes, KarstenK is correct. If I were you, I would preload all the bitmaps and maintain handles to them. Then when the selection changes building your list will be very fast because you don't have to load any of them. You can just assemble the...
26 Aug 2022 by Fatima Zahid 2022
// Project36,a car variable as userdefined datatype.cpp : This file contains the 'main' function. Program execution begins and ends there. #include #include #include using namespace std; char structurecar() { ...
26 Aug 2022 by OriginalGriff
Simple: you are reading a single character into a and assuming that it will hold everything. It won't, its a char not a string, so it holds just one character: 'A', 'z', or ';'. If you want more data, you need to allocate space for it! Try...
26 Aug 2022 by CPallini
Your code doesn't resemble C++ 'typical' one. Try #include using namespace std; class Car { private: string m_name, m_model; int m_horsepower; public: Car( string name, string model, /* ... */ int horsepower) : m_name{name},...
13 Nov 2019 by Mikhail Semenov
This article discusses an implementation of multidimensional array class with resizable dimensions. Access to subarrays and their swapping are allowed. Benchmarks are provided, which compare the performance of this implementation with Boost and standard C arrays.
20 Aug 2023 by honey the codewitch
I have an issue where I'm writing out a simple 8-bit grayscale bitmap as I read it from a stream. The issue is this: I'm going top to bottom left to right, and attempting to read the pixels out of the bitmap sequentially. I feel like this...
20 Aug 2023 by Andre Oosthuizen
From what I could read (might be missing the ball completely) - There shouldn't be a need for the extra seek operation, as you're already calculating the offset based on the pixel's position. It is possible that the issue might be related to the...
20 Mar 2018 by Member 3733166
Run the the following program twice. Once with the given destructor and once with "std::fesetround(value);" removed from the destructor. Why do I receive different outputs? Shouldn't destructor be called after function "add"? #include #include #include struct...
20 Mar 2018 by Jochen Arndt
The destructor is called when the object goes out of scope. That is after the add() call in your code. But the rounding mode affects also string conversions. So the difference in the output is not created by the add() operations but by printing out the results: - With resetting the mode cout...
20 Mar 2018 by CPallini
It is a cout artifact. Try, for instance std::cout
10 Sep 2022 by Mikhail Semenov
This article shows that double-ended vector is much faster than std::deque and should be preferred.
23 May 2021 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
23 May 2021 by Patrice T
Quote: Kick start 2021 round C Your problem is that your code is not related to Google's problem. Your task is to write code solving the requirement. The word 'problem' in Google's problem is a requirement, the word 'problem' in your code is...
26 Aug 2018 by Member 13927859
Hi , I try to access to main window from a dialog box which is the login interface. My scenario is to check if the psw is correct ,then it shows the window frame (SDI) (if the PSW is correct) by clicking on "Enter" key board (not an OK button). I will work with dialog box and SDI . My problem is...
24 Aug 2018 by Member 13927859
BOOL CIntClientApp::InitInstance() { // InitCommonControlsEx() est requis sur Windows XP si le manifeste de l'application // spécifie l'utilisation de ComCtl32.dll version 6 ou ultérieure pour activer les // styles visuels. Dans le cas contraire, la création de fenêtres échouera....
26 Aug 2018 by Member 13927859
I try with this code , but also ,I can access to second interface with an incorrect PSW. void CLoginDlg::OnLogin() { UpdateData(TRUE); CWnd* pwndCtrl = GetFocus(); int ctrl_ID = pwndCtrl->GetDlgCtrlID(); CLoginDlg LoginDlg; switch (ctrl_ID) { case IDC_EDIT_PSW: UpdateData(TRUE);...