visual-c++

Why does my code fail to create a directory in “C:\Program Files” under Windows 7?

南楼画角 提交于 2020-01-16 18:15:28
问题 I am using Windows 7 and I have to run one program in that windows but that program working in Windows XP. This is a Visual C++ program and I am using Visual Studio 2008 for this. When I am running my application, it does not throw any errors, but it does not create a directory in "c:\program files\". So can anyone help me to create directory and exe file? This is the code I am using: char szAppPath[MAX_PATH]; char szFileName[MAX_PATH]; DWORD dwResult; WIN32_FIND_DATA FindFileData; HANDLE

Add two fraction

試著忘記壹切 提交于 2020-01-16 12:00:10
问题 #include <iostream> using namespace std; class Fraction { private: int num; int denom; public: Fraction() { int num = 0; int denom = 1; } Fraction(const Fraction& ref) { num = ref.num; denom = ref.denom; } Fraction(int arg) { num = arg; denom = 1; } Fraction(int arg, int arg2) { num = arg; if (arg2 == 0) denom = 1; else denom = arg2; } ~Fraction() { } void setnum(int arg) { num = arg; return; } void setdenom(int arg) { if(arg) { denom = arg; } else { denom = 1; } return; } int getnum() const

Add two fraction

情到浓时终转凉″ 提交于 2020-01-16 11:59:07
问题 #include <iostream> using namespace std; class Fraction { private: int num; int denom; public: Fraction() { int num = 0; int denom = 1; } Fraction(const Fraction& ref) { num = ref.num; denom = ref.denom; } Fraction(int arg) { num = arg; denom = 1; } Fraction(int arg, int arg2) { num = arg; if (arg2 == 0) denom = 1; else denom = arg2; } ~Fraction() { } void setnum(int arg) { num = arg; return; } void setdenom(int arg) { if(arg) { denom = arg; } else { denom = 1; } return; } int getnum() const

Is the ClCompile item a task as well?

≯℡__Kan透↙ 提交于 2020-01-16 11:23:08
问题 I am trying to understand the visual cpp project document here (https://docs.microsoft.com/en-us/cpp/build/walkthrough-using-msbuild-to-create-a-visual-cpp-project). <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release<

Is the ClCompile item a task as well?

给你一囗甜甜゛ 提交于 2020-01-16 11:23:07
问题 I am trying to understand the visual cpp project document here (https://docs.microsoft.com/en-us/cpp/build/walkthrough-using-msbuild-to-create-a-visual-cpp-project). <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release<

“Call Stack” for C++ errors in Visual Studio 2005

我与影子孤独终老i 提交于 2020-01-16 09:44:30
问题 Is there a "call stack" for compiler errors in Visual Studio 2005 (C++)? For example, I am using a boost::scoped_ptr as the value in a QHash. This is however causing the following compile error: 1>c:\qt\include\qtcore\../../src/corelib/tools/qhash.h(743) : error C2248: 'boost::scoped_ptr<T>::operator =' : cannot access private member declared in class 'boost::scoped_ptr<T>' From the build output I know which of my source files is causing the error and the line number in the qhash.h that is

Confusing flags passed to MSVC through NVCC with CMake

对着背影说爱祢 提交于 2020-01-16 08:40:20
问题 I have a CMake file which I'm using to build some CUDA on Windows (NVCC/MSVC). I'm trying to set the MSVC warning level to /W4 , using: add_compile_options("$<$<COMPILE_LANGUAGE:CUDA>:--compiler-options=/W4>") Building with CMake 3.9, I get this warning: (CudaBuildCore target) -> cl : Command line warning D9025: overriding '/W4' with '/W3' In CMake 3.15, the policy was changed to not automatically set /W3 in the CUDA flags, but with that version I get: (CudaBuildCore target) -> cl : Command

How to return value from nested task in c++/cx?

我与影子孤独终老i 提交于 2020-01-16 02:33:11
问题 I have a bunch of threaded tasks like this after each other: create_task(somewinrtasyncfunction()).then([this(variable_that_the_last_task_returned) { //task here return info; }).then([this](info) { //another task here return status}); Now I want to use status outside the tasks, in the function that called it. How would I access it? 回答1: You return the task (or value) created by create_task(...).then(...).then(...) . If you need to get the result synchronously, you can try calling .get() on

Winapi CreateDC hangs on Win 8

天涯浪子 提交于 2020-01-16 02:08:06
问题 I have a program which uses winapi functions. When it runs on WinXP (32bit) or Win7 (64bit) everything is OK. But on Win8 (64bit) there is a bug: sometimes program hangs on this code line HDC hDisplay = CreateDC("DISPLAY", NULL, NULL, NULL); What might be the reason of it? p.s. It is built in MSVC 2005 on WinXP 32 bit for platform Win32. 回答1: Try: CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL) 回答2: I have managed to rebuild program for 64bit platform, and it works now. 回答3: While this question is

Adding floats with gmp gives “correct” results, sort of

偶尔善良 提交于 2020-01-16 00:48:06
问题 In the code below I use mpf_add to add the string representation of two floating values. What I don't understand at this point is why 2.2 + 3.2 = 5.39999999999999999999999999999999999999 . I would have thought that gmp was smart enough to give 5.4 . What am I not comprehending about how gmp does floats? (BTW, when I first wrote this I wasn't sure how to insert a decimal point, thus the plus/minus digit stuff at the end) BSTR __stdcall FBIGSUM(BSTR p1, BSTR p2 ) { USES_CONVERSION; F(n1); F(n2)