剑指offer代码 vs2013执行

方法:

代码文件夹名称为:CodingInterviewChinese2-master

1. 用vs2013加载解决方案 .sln文件

2. 一个解决方案下面有多个项目,通过右键解决方案->属性->通用属性->启动项目... 可以设置单项启动项目

    选择单项启动,选中一个项目然后确定。发现解决方案下面对应的项目名称字体加粗了。

   或者,直接右键想要启动的项目点击 “设置为启动项” 即可。

3. 右键该项目,点击重新生成解决方案,出现错误如下:

错误 1 error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install v140 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Upgrade Solution...". C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V120Microsoft.Cpp.Platform.targets 64 5 39_MoreThanHalfNumber

解决方法:右键该项目:属性->配置属性->平台工具集成 ,,,,,  下拉菜单,将v140 (未安装)修改成自己vs版本Visual Studio 2013 (v120) 然后确定。

4. 右键项目,重新生成解决方案,成功!

5. Ctrl+F5 开始执行。

若不按照该方法,可能会出现错误: vs2013无法启动程序,系统找不到指定的路径

 

另外:若在生成过程中遇到类似错误(预处理器定义问题):

错误 1 error C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. f:c++_exstring_exstring_exmain.cpp 93 1 string_ex

解决方法:右键该项目属性->配置属性-> c/c++ ->预处理器->预处理器定义,,, 编辑,添加上面黑色字体_CRT_SECURE_NO_WARNINGS 部分确定即可。

在一个解决方案下面添加多个项目工程:
右键解决方案->添加->新建项目...... 就可以添加新的项目了。

然后,将该项目设置为启动项,生成解决方案,即可运行该项目。

原文地址:https://www.cnblogs.com/Allen-rg/p/6889889.html