c++ - Visual C++ 2008 问题

标签 c++ visual-studio-2008

好吧,这太蠢了,我有 Microsoft Visual Studio 2008,工作正常,现在每当我运行 .cpp 程序时,我的命令提示符窗口默认颜色为灰色,而我最初的输出是柠檬绿。

错误信息:

'Testing.exe': Loaded 'C:\Users\codebox\Documents\Visual Studio 2008\Projects\Testing\Debug\Testing.exe', Symbols loaded.
'Testing.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll'
'Testing.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
'Testing.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
'Testing.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcp90d.dll'
'Testing.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcr90d.dll'
The program '[2644] Testing.exe: Native' has exited with code 0 (0x0).

为什么IDE加载Testing.exe,我 只是想测试一个 .cpp?

下面的代码工作正常,除了,现在我收到上面的错误消息,我怀疑 IDE:

// This program will assist the High Adventure Travel Agency
// in calculating the costs of their 4 major vacation packages.
#include <iostream>
#include <iomanip>
using namespace std;

// Constants for the charges.
const double CLIMB_RATE = 350.0;       // Base rate - Devil's Courthouse
const double SCUBA_RATE = 1000.0;      // Base rate - Bahamas
const double SKY_DIVE_RATE = 400.0;    // Base rate - Sky diving
// This program is a driver for testing the showFees function.
#include <iostream>
using namespace std;

// Prototype
void showFees(double, int);

int main()
{
   // Constants for membership rates
   const double ADULT = 40.0;
   const double SENIOR = 30.0;
   const double CHILD = 20.0;

   // Perform a test for adult membership.
   cout << "Testing an adult membership...\n"
        << "Calling the showFees function with arguments "
        << ADULT << " and 10.\n";
   showFees(ADULT, 10);

   // Perform a test for senior citizen membership.
   cout << "\nTesting a senior citizen membership...\n"
        << "Calling the showFees function with arguments "
        << SENIOR << " and 10.\n";
   showFees(SENIOR, 10);

   // Perform a test for child membership.
   cout << "\nTesting a child membership...\n"
        << "\nCalling the showFees function with arguments "
        << CHILD << " and 10.\n";
   showFees(CHILD, 10);
   return 0;
}

//*****************************************************************
// Definition of function showFees. The memberRate parameter      *
// the monthly membership rate and the months parameter holds the *
// number of months. The function displays the total charges.     *
//*****************************************************************

void showFees(double memberRate, int months)
{
    cout << "The total charges are $"
         << (memberRate * months) << endl;
}

遇到这种情况,一个人应该如何启动他/她的代码? 或者我想改变什么,我只想用 C++ 编写代码并测试我的代码,仅此而已,而不是乱用该死的 IDE。

Solution: Ctrl+5

http://msdn.microsoft.com/en-us/library/ms235629.aspx

To build and examine the program

1.

  On the Build menu, click Build Solution.

  The Output window displays information about the compilation

progress, for example, the location of the build log and a message that states the build status. 2.

  On the Debug menu, click Start without Debugging.

  If you used the sample program, a command window is displayed and

shows whether certain integers are found in the set.

最佳答案

没有错误...您报告的消息只是 VC++ 通知您加载了哪些 dll、哪些调试符号可用等。最后一行告诉您程序终止并返回代码 0。如果您不这样做看不到您的程序正在运行,这只是因为它非常快,并且在结束时控制台会自动关闭。

要查看程序的输出,您有多种选择:您可以在返回 0 时设置一个断点(这样程序就暂停在那里,您可以在它关闭之前查看控制台窗口),或者您可以在不调试的情况下启动程序(在这种情况下,VC++ 会要求您在结束程序之前按一个键);你也可以添加行

cout<<"Press Enter to exit.";
cin.sync();
cin.ignore();

在返回 0 之前:以这种方式,退出前的按键将包含在应用程序中(不过,我不推荐这种方法,因为如果你想从一个已经打开的控制台运行程序,你最终会得到总是在应用程序结束时出现烦人的消息)。

顺便说一句,这个问题可能保持着关于 VC++ 和许多其他 IDE 的“最常被问到的问题”的记录:)

Why is the IDE loading Testing.exe, I just want to test a .cpp?

您知道...要运行 .cpp,您必须先编译它...您从编译中得到什么?一个 .exe... >_>

I just want to code in C++ and test my code that's all, not mess around with the damn IDE.

当您必须调试大型应用程序时,您会祝福那个“该死的 IDE”。

关于c++ - Visual C++ 2008 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1946067/

相关文章:

python - 使用 python 驱动程序将数据传入和传出 C++ 代码

c++ - Qt : Drawing Blended Transparent Lines/Curves/Paths

C#.NET : A graphical control makes my app freeze after workstation unlock

visual-studio-2008 - Visual Studio 2008 - 禁用 .NET Framework 调试

c# - .Net 框架开发人员在 Mono 中的局限性

c++ - 什么时候会发生内存泄漏?

if-else 中的 C++11 lambda 函数定义

c++ - std::declval 是如何工作的?

visual-studio-2008 - 从源代码管理中排除嵌套项

visual-studio-2008 - 在C++/CLI项目中嵌入资源