Click here to Skip to main content
15,888,733 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 Updated

C++17 

15 Dec 2020 by alex bottom122323
I want to try making classes and objects but it's giving me some errors which I am not able to resolve. Below is my code: #include using namespace std; class employee{ int count; int id; public: void set(void){ ...
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); }
14 Jun 2019 by altomaltes
As a low entropy IDE, you can try code::blocks Just install it and do File->new->project->win32 gui project Choose C++ when asked. This will create a minimal debuggable c++ project. Stepping and breakpointing it can help to understand. I don´t advice Visual Studio because is more about Microsoft...
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...
8 Jan 2024 by awesome priyanshu
#include using namespace std; int main() { int n, m; cin >> n >> m; int sock = n; int count = 0; while (sock > 0) { count+=1; if (sock % m == 0) { sock++; } ...
7 Nov 2023 by bartello
I wrote a very simple chat server using boost::asio. Everything works as it should. As I just redid the TCPSession class to use "strand", there was an error in the functionality of the class: The server accepts a connection and immediately drops...
25 Nov 2018 by Bartlomiej Filipek
What performance can we get from C++17 parallel algorithms?
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++
20 Jun 2023 by Coral Kashri
CoreC++ talk - experience summarize, and self opinions
20 Mar 2018 by CPallini
It is a cout artifact. Try, for instance std::cout
30 Nov 2018 by CPallini
Yes, it looks a compiler problem (at least g++-7 compiles it without complaining). Why don't you an std::array, instead auto myArray = std::make_shared>(); ?
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[^].
15 Dec 2020 by CPallini
As suggested, you could try a more idiomatic approach: #include using namespace std; class employee { int id; int count; public: employee(int id, int count): id(id), count(count){} void set_count(int new_count) { ...
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},...
9 Nov 2023 by CPallini
You forgot to include the new header which provides standard library implementations of the placement new (as an alternative, you could provide your own implementations). The following code compiles and runs fine on my Linux box. #include...
19 Oct 2022 by CPallini
Are you possibly searching for popen? See, for instance: The Marvelous popen() Function | C For Dummies Blog[^]
14 Jun 2019 by da.ko
Where should I start if I want to learn in a hands-on capacity. I know a bit of c++ syntax but I don't know how to use c++ with a GUI. What project should I start with to learn through hands-on research and trial and error? What I have tried: This. Plus all these extra chars so I am over thirty.
10 Aug 2020 by Damian Reloaded
List comprehensions in C++
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.
30 Aug 2023 by Dave Kreskowiak
Why would you want to launch an entirely separate process (rundll32) that will not communicate with your app at all? Using the query window will do nothing in your application. You app will never know the user did anything in that window because...
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.
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...
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...
26 Sep 2022 by Death Smoke
I'm trying to make a connection between two computers both of them are using tp-link adapter , but i'm not receving anything from client . #include #include using namespace std; int main() { ...
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...
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 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 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...
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() { ...
17 Oct 2020 by George Shagov
Two and three states Fibonacci Rabbit's Machines
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
3 Jan 2020 by goranorsander
A class template for specializing fundamental types
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...
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...
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 =...
5 Dec 2022 by Harsh 5
The question is straightforward but the only thing I cannot conquer is getting the elf's calorie data as input from the user. I have to read for a new line and whenever I get a new line I have to update my sum to the maximum calorie/sum an elf...
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,...
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.
3 Jun 2021 by honey the codewitch
Explore techniques for drawing using GFX
9 Jan 2023 by honey the codewitch
A project that allows you to use a knob to control a fan's RPM with feedback
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...
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...
8 Nov 2023 by honey the codewitch
new expression - cppreference.com[^] Useless. Placement new operator in C++ - GeeksforGeeks[^] Bunk. Placement syntax - Wikipedia[^] Written by somebody who doesn't care if it's understood by anyone. Apparently I can't read code. Apparently...
29 Aug 2023 by Inczu
How can I make an edit control updating itself in MFC App? I want to write down data in three edit controls (void CServicesDlg::EdtCompanyName(), void CServicesDlg::EdtServiceName() and void CServicesDlg::EdtPortTCP()) and make one edit control...
13 Sep 2023 by Inczu
I want to create an edit control that when I write something in first edit control void CSecondDlg::EdtUserName() makes second edit control void CSecondDlg::EdtWichUser() write down the same thing automatically. What I have tried: I searched...
12 Sep 2023 by Inczu
When I am writing in first dialog IDD_SERVICES_DIALOG ServicesDlg.cpp edit control void CServicesDlg::EdtCompanyName() and click at a button void CServicesDlg::BtnNextSecondDlg(), I want to put this data to third dialog IDD_DIALOG2 ThirdDlg.cpp...
13 Sep 2023 by Inczu
I want to create a code that will find if the password "xsw2!QAZ" in edit control void CSecondDlg::EdtFirstPassword() is correct when you select radio button void CSecondDlg::RadIsntExist() and then select user "Test" from combobox void...
13 Sep 2023 by Inczu
I want to create in MFC App a combobox void CSecondDlg::ComboExistUser() that adds users and groups from any folder -> properties -> security -> edit -> add -> advanced -> search now -> search Results. If some user or group is added previously,...
13 Sep 2023 by Inczu
In my MFC app, when I click button void CSecondDlg::BtnSearchUsers(), it will do this: ShellExecute(nullptr,_T("open"),_T("rundll32.exe"),_T("dsquery.dll,OpenQueryWindow"), nullptr, SW_SHOWNORMAL); (it will go to this system dialog). When I...
13 Sep 2023 by Inczu
I've created a rich edit control in IDD_DIALOG2, ThirdDlg.cpp. When I click button void CSecondDlg::BtnNextThirdDlg() to go to the next dialog ThirdDlg.cpp, I can't go there because I have an error: "Services.exe has triggered a breakpoint". When...
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...
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.
8 Dec 2021 by John M. Dlugosz
A simple pair of iterators provides many handy use cases
23 Jun 2018 by John M. Dlugosz
Using the new structured binding feature in your API design
6 Apr 2020 by Jovibor
Owner-draw list control with tooltips, editing, colors, sorting, hyperlinks, columns hiding and lot more.
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...
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...
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...
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.
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 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.
7 Sep 2023 by KarstenK
You need to use the debugger. The most common case for your error, is that the control isnt correctly connected with some resource in the rc and wiward. ASSERT(::IsWindow(m_hWnd)): means that this object hasnt a window handle. So debug to find...
13 Sep 2023 by KarstenK
You should use a more structural approach and use some data model for your combobox. Like an array of strings or suitable objects. This model can you than search or modify and than make a complete reload. Learning about the guts of the MFC is...
16 Mar 2024 by Line Item
I would try running this from a command line, with some adjustments for that to make it a simple command. Get that to work then add to that a little at a time. Maybe then try moving that to PowerShell. Get that to work then add more until you...
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
30 Mar 2020 by Maciej Los
Please, follow the instruction from MSDN: Linker Tools Error LNK2019 | Microsoft Docs[^]
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...
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.
3 Mar 2019 by MehreenTahir
This article is a continuation of Programming Concurrency in C++ Part 1. We will discuss synchronization, future and promises along with async and with that, will sum up the introduction of concurrency in C++.
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...
15 Dec 2020 by Member 12982558
get and set are functions and need parentheses
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);...
30 Nov 2018 by Member 14068785
Dear experts, I have a simple code which uses shared_ptr with arrays. The line of the code that gives problem is: std::shared_ptr myArray(new double[10]); I'm using a Mac OS 10.14.1 and Xcode 10.1 from command line: c++ -std=c++17 -o sharedPtr sharedPtr.cpp Apparently I think it...
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...
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 ...
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*...
23 Jan 2022 by Member 15509751
Our code team encountered the same issue with a shared_ptr to an array with Mac's version of the clang compiler. Your syntax is correct and will work with the gcc (not Mac's alias to their clang compiler), llvm, etc. -- we verified 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...
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...
5 Dec 2022 by merano99
Saving the calories in a vector would be a good idea. std::vector numbers; Then it would be practical to write the calories as described in a file calories.txt and read this file line by line. At each blank line write the sum into the...
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 Aug 2023 by merano99
Rick has already written the basic solution in Solution1, here again in more detail: To display a summary of three other text fields in the text field EdtDescription, a simple solution would be to react on EN_CHANGE of the three fields and call...
29 Aug 2023 by merano99
I guess this is asking for a way to list users and rights groups via the Win32 API. One possibility would be this: Enumerating Users: Enumerating Users - Win32 apps | Microsoft Learn[^]
1 Sep 2023 by merano99
Presumably the question again concerns an edit control in a dialog. There were already answers for this. MFC app edit control updating itself[^]
4 Sep 2023 by merano99
If I interpret the question correctly there are two dialogs ServicesDlg and CThirdDlg. On the ServicesDlg dialog there is an Edit control EdtCompanyName and a button BtnNextSecondDlg. If you press the button, the text from EdtCompanyName should...
5 Jan 2018 by Michael Chourdakis
The most appealing (to me!) new C++ features
7 Jan 2018 by Michael Chourdakis
Reduce function recursion with variadic templates
4 Mar 2020 by Michael Chourdakis
A small player for your clue game
20 Jan 2024 by Michael Chourdakis
A set of tools to create a new VCXPROJ file automatically
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, ...
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.
10 Sep 2022 by Mikhail Semenov
This article shows that double-ended vector is much faster than std::deque and should be preferred.
18 Sep 2022 by Mikhail Semenov
This article proposes a mapping algorithm, called Segmented Map, which is almost as fast as Flat Map is random access and enumeration of elements and close to std::map in insertion of elements.
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...