Click here to Skip to main content
15,889,096 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 

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...
30 Jan 2024 by steveb
Use a WinMain without the window creation
27 Jan 2024 by Shao Voon Wong
C++17 easy string to number and vice versa conversions in header-only class
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 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 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 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...
20 Jan 2024 by Michael Chourdakis
A set of tools to create a new VCXPROJ file automatically
8 Jan 2024 by OriginalGriff
As soon as sock is divisible by m, it is incremented and immediately decremented again - so the next loop iteration has the same value of sock and the loop never exits. Since the loop never exits, the code never reaches the cout and you never see...
8 Jan 2024 by Richard MacCutchan
I think the problem is here: if (sock % m == 0) { sock++; } sock--; // If you add 1 to sock and then subtract 1 it will go on for ever but I am not sure what those lines of code are supposed to do.
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++; } ...
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...
8 Nov 2023 by Richard MacCutchan
Your call to operator new is not quite correct. It goes something like: // // new(a) type; calls operator new(sizeof(type), a); // new(a,b) type[42]; calls operator new(sizeof(type)*42, a, b); // thus // new(T) calls operator new(sizeof(T)); //...
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...
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...
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?
19 Sep 2023 by sebjameswml
morph::vvec allows you to do vector math without any external libraries
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...
13 Sep 2023 by Rick York
I think jeron1 is on the right track with his comment. Try adding few lines of code like this : else { CDialog dlg(IDD_DIALOG1, this); #ifdef _DEBUG // additions begin here if( IsWindow(...
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...
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 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
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...
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...
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...
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...
7 Sep 2023 by Rick York
Your problem seems obvious because the message told you what it is : Quote: "Debug Assertion Failed!" "Services.exe has triggered a breakpoint." on line 628 { ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, BM_GETCHECK, 0, 0); } in...
6 Sep 2023 by OriginalGriff
We can't tell, we have no access to your code while it is running, so we have no idea what is in m_RadIsntExist or what it should contain. So, it's going to be up to you. Fortunately, you have a tool available to you which will help you find out...
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...
4 Sep 2023 by Richard MacCutchan
You keep repeating what is essentially the same question, and expecting ChatGPT to write the code for you, which is unlikely. And as I keep telling you, you can find out all you need to know about edit controls at CEdit Class | Microsoft Learn[^].
1 Sep 2023 by Richard MacCutchan
You cannot expect there to be YouTube tutorials on every question you come up with. As already suggested, you should use the documentation to check what features are available in each control that you are using: CEdit Class | 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[^]
1 Sep 2023 by OriginalGriff
That's a little complicated, because generally speaking two instances of a control shouldn't even know that the other exists - it breaks OOPs principles if they do, unless one is the child of another (and parent-child is trivial, so I'm pretty...
31 Aug 2023 by steveb
You need to use API NetUserEnum and NetQueryDisplayInformation NetUserEnum NetQueryDisplayInformation and link with Netapi32.lib include Lm.h And with all that information you can populate you dialog's combo box.
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...
30 Aug 2023 by Richard MacCutchan
Using AI is largely a waste of time to solve programming issues, or research "how to" questions. Microsoft provides a comprehensive set of documentation that you should make use of. Using ShellExecute runs the search in a separate Window. So...
29 Aug 2023 by Rick York
The previous solutions have given information with useful references. I will point out a very, very handy method of the CComboBox class. That is SetItemDataPtr. If this were my problem, I would first assemble the collection of users, and then...
29 Aug 2023 by Richard MacCutchan
Your time would be better spent studying the documentation for the CComboBox Class | Microsoft Learn[^]. It is a simple matter to use one of the Findxxx methods to checlk if an entry already exists before adding it to the list.
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[^]
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...
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...
23 Aug 2023 by Rick York
It is not entirely clear what you are trying to do. You state you want to have an edit control update itself but then you list it as CServicesDlg::EdtCompanyName(). That is clearly a method of a dialog class and it is unclear what relationship...
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 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 Jun 2023 by Coral Kashri
CoreC++ talk - experience summarize, and self opinions
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. ...
6 May 2023 by Richard MacCutchan
Why not use the features provided: NtQueryInformationProcess function (winternl.h) - Win32 apps | Microsoft Learn[^] ?
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 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 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...
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
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++
9 Jan 2023 by honey the codewitch
A project that allows you to use a knob to control a fan's RPM with feedback
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...
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...
5 Dec 2022 by OriginalGriff
Quote: The below code is what I have tried but it's entirely wrong! Yes. It is. And you don't know why. Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. How you use it depends on your...
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...
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, ...
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[^]
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...
19 Oct 2022 by CPallini
Are you possibly searching for popen? See, for instance: The Marvelous popen() Function | C For Dummies Blog[^]
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); }
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...
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() { ...
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.
10 Sep 2022 by Mikhail Semenov
This article shows that double-ended vector is much faster than std::deque and should be preferred.
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 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},...
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 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 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...
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 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...
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
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...
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
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...
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.
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...
8 Dec 2021 by John M. Dlugosz
A simple pair of iterators provides many handy use cases
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 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...
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...
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 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...
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 =...
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 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...
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.
28 Aug 2021 by RegularJoe5150
A reformulation of compressed pair into a type list
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. ...
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,...
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...
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.