c++

Writing and Reading .dat file from integer multidimensional array c++

I have an integer multidimensional array of commands. I want it to be written into a .dat file, then later in the program, it will be read and the data written will be used for other parts of the program. static int commands[][2]= {{5,1}, {2,0}, {5,4}, {3,0}, {5,1}, {3,0}}; //create file if first time ofstream oFile(“data.dat”, ios::out); if(!oFile){ cerr <<…
Read more

objectGuid to immutableid conversion

In adsi c++ i want to convert objectGuid retrieved from on premise AD to immutableId string. (Office 365 ImmutableId attribute). How to do it in c++? [ in c# this can be done through: Guid guid = new Guid(guidStr); String immutableIdStr = Convert.ToBase64String(guid.ToByteArray()); ] Source: c++

GetModuleFileNameEx – Split output

I trying to get process name from the process id, and I’ve use GetModuleFileNameEx and I write this function. char* ProcessName(ULONG_PTR ProcessId) { char szBuffer[MAX_PATH+1]; HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ | PROCESS_TERMINATE, FALSE, ProcessId); if(GetModuleFileNameEx(hProcess, NULL, szBuffer, MAX_PATH) == 0) sprintf(szBuffer, “null”); CloseHandle(hProcess); return szBuffer; } the output is Full-Path&Process-Name, and I want split it so I can get…
Read more

Why std::remove takes const version of iterators? [duplicate]

This question already has an answer here: Why does std::remove not work with std::set? 1 answer I am using Visual Studio 2013 to compile very simple code: std::set<int> a{ 1, 2, 3 }; std::remove(a.begin(), a.end(), 3); I expect this can’t go wrong but I am surprised. Error emits: Error 1 error C3892: ‘_Next’ : you cannot assign to a variable…
Read more

xtgmath.h has compile-time errors

I am trying to compile an older C++ program in Visual Studio 2013 Professional. I am encountering a compile error, with Visual Studio saying that there are syntax errors in the xtgmath.h file. The complete log is: 1> fill.cpp 1>C:Program Files (x86)Microsoft Visual Studio 12.0VCincludextgmath.h(179): error C2059: syntax error : ‘(‘ 1>C:Program Files (x86)Microsoft Visual Studio 12.0VCincludextgmath.h(179): error C2027: use…
Read more

Force threads to leave object before destruction

When using multithreading I often run into the following problem: I’ve got an object, say a network receiver(but could be anything). And a function that gets the data. Now sometimes there simply is no data, and you want to let the thread wait to get it’s data. A blocking call, very much like being used by Berkeley sockets and it’s…
Read more

Why Did This Program Not Complie – C++

#include <iostream> #include<iomanip> using namespace std; int main() { const int NUMROWS=3; const int NUMCOLS=4; int i,j; int val[NUMROWS][NUMCOLS]={8,16,9,52,27,6,14,25,2,10};//multiply each element by 10 and display it cout<<“nDisplay or multiplied elements”; for(i=0; i<NUMROWS;i++) { val[i][j]=val[i][j]*10; }//end of inner loop }//end of outer loop cout<endl; return 0; } These are the errors I received. What have I done wrong 16:5: error: ‘cout’…
Read more