Tuesday, September 15, 2015

Dev-C++ Errors and Solutions

Issue: [Error] 'ofstream' was not declared in this scope

Problem code snippet:
#include <iostream>
#include <fstream>
int main() {
    ofstream myfile;

// TO DO........

    return 0;
}

Solution code snippet:
#include <iostream>
#include <fstream>

using namespace std;

int main() {
    ofstream myfile;

// TO DO........

    return 0;
}



Issue: [Error] cannot convert 'const wchar_t*' to 'LPCSTR {aka const char*}' for argument '1' to 'HINSTANCE__* LoadLibraryA(LPCSTR)'

Problem code snippet:
s_hKernel = LoadLibrary( L"Kernel32.dll" );

Solution code snippet:
s_hKernel = LoadLibrary( "Kernel32.dll" );



Issue: [Error] cannot convert 'PROCESS_MEMORY_COUNTERS_EX* {aka _PROCESS_MEMORY_COUNTERS_EX*}' to 'PPROCESS_MEMORY_COUNTERS {aka _PROCESS_MEMORY_COUNTERS*}' for argument '2' to 'WINBOOL GetProcessMemoryInfo(HANDLE, PPROCESS_MEMORY_COUNTERS, DWORD)'

Problem code snippet:
PROCESS_MEMORY_COUNTERS_EX pmc;
GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc));

Solution code snippet:
PROCESS_MEMORY_COUNTERS_EX pmc;
GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc));

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.