[Solved] Windows message loop and server loop

This is a very confusing question as it asks one question in the title, but the content addresses a different problem (threads crashing). To address the primary question: Microsoft did add a way to handle socket communications in a GUI thread friendly way: WSAAsyncSelect. This will send socket events as messages to your applications message … Read more

[Solved] printing array in reverse order avoiding duplicates c++

You should initialize last, otherwise it will be filled with garbage and according to your logic, it will print last. int last = arr[lengthOfArray-1]; int count = 0; for(int i = lengthOfArray-1; i >=0; i–){ if(last == arr[i]){ ++count; } else{ cout << last << endl; count = 1; } last = arr[i]; } if … Read more

[Solved] Why my output isn’t correct?

I commented the changed portion and explained why. I didn’t change your code, so that you can understand easily. Try this : #include <stdio.h> #include <stdlib.h> #include <string.h> struct AdjListNode { char *dest; struct AdjListNode* next; }; struct AdjList { struct AdjListNode *head; // pointer to head node of list }; struct Graph { int … Read more

[Solved] Error while saving changes to custom config file [closed]

Requirements using System.Configuration; Read var appSettings = ConfigurationManager.AppSettings; string result = appSettings[key] ?? “Not Found”; Write var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var settings = configFile.AppSettings.Settings; if (settings[key] == null) { settings.Add(key, value); } else { settings[key].Value = value; } configFile.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name); solved Error while saving changes to custom config file [closed]

[Solved] Dividing one column into two columns in SQL [duplicate]

try this: DECLARE @YourTable table (Column1 varchar(50)) INSERT @YourTable VALUES (‘Frodo Baggins’) INSERT @YourTable VALUES (‘Samwise Gamgee’) INSERT @YourTable VALUES (‘Peregrin Took’) INSERT @YourTable VALUES (‘Meriadoc Brandybuck’) INSERT @YourTable VALUES (‘aa’) INSERT @YourTable VALUES (‘aa bb cc’) SELECT LEFT(Column1,CHARINDEX(‘ ‘,Column1)) AS Names ,RIGHT(Column1,LEN(Column1)-CHARINDEX(‘ ‘,Column1)) AS Surnames FROM @YourTable –both queries produce same output SELECT SUBSTRING(Column1, … Read more

[Solved] Wait for message delivered to MainWindow sent using SendMessage API

Here is the sample code in C++,(Removed error checking) MainWindow.cpp: #include <windows.h> #include <iostream> LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } DWORD WINAPI createyourwindow(LPVOID param) { WNDCLASSEXW wcex = { 0 }; wcex.cbSize = … Read more

[Solved] C program not printing out correct output

printf(“%.3f+%.3fi”, ((-b) / (2*a)), (sqrt(d) / (2 * a))); You are using integer division in ((-b) / (2*a)) So you will get incorrect values for some numbers. You can use. printf(“%.3f+%.3fi”, ((-b) / (2.0*a)), (sqrt(d) / (2 * a))); to force a conversion to a double before the division. You need to do this for … Read more

[Solved] Array Struct Not Printing Correctly

In every function you are starting from array[-1], and in C/C++ you won’t get an exception it will just take what is in memory before the array. Change [student-1] to [student] and initialise sum to 0. Advice for future: don’t use ‘magic numbers’ in loops, declare them as a variable and then you can just … Read more

[Solved] Password cracker returning _Parent_proxy was 0xCCCCCCCC

Your code has undefined behaviour: foo.cc: In function ‘std::__cxx11::string Generate(unsigned int, std::__cxx11::string)’: foo.cc:87:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ Turn on compiler warnings in your compiler and read them. Once you’ve done that and see that your code doesn’t do what you intended think of why Generate can not generate all … Read more

[Solved] How to change ASCII table data? [closed]

An example using a std::map as suggested in the comments could look like this: #include <iostream> #include <map> int main() { // a map from char (key) to int (value) std::map<char, int> ascii_map; // put the normal ASCII values in the map for(int ch = 0; ch <= 127; ++ch) ascii_map[static_cast<char>(ch)] = ch; // make … Read more

[Solved] How the array work in c?

Please note, the third for loop is nested inside the second loop. So, for each value of j in the other loop body like 0, 1, 2, the inner loop will execute for each time. If you’re bothered that after the first loop, j will be 10, then don’t worry, the statement-1 in the second … Read more