Visual Studio 2015 - 本地Windows调试器在运行后立即关闭?

时间:2016-04-13 16:18:30

标签: c++

嗨,我是一名需要帮助的高中生。我对C ++感兴趣,因为我希望有一天能成为一名程序员。我开始使用Visual Studio for C ++,我正在运行几行简单的代码。但每次按(Ctrl + F5)或本地Windows调试器它都会显示我的代码行,但它在运行后立即关闭,几乎无法读取。代码是经典的“Hello World!”码。也许它必须做一些返回0;?

编辑:这是我的代码。

#include <iostream>
using namespace std;

int main()
{
    int mark = 90;
    if (mark < 50) {
        cout << "HES OLD" << endl; 
    }
    else {
        cout << "Hes not old!" << endl;
    }
}

1 个答案:

答案 0 :(得分:0)

在制作控制台应用程序时,我在std::cout << "\nPaused. Press Enter to continue.\n"; std::cin.ignore(100000, '\n'); 函数的末尾使用以下行:

 [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public String removeTree(int id)
    {
           try
            {
                using (var context = new Data.Entities())
                {
                    var delNode = context.Tree.Where(c => c.ID == id).First();
                    if (delNode != null)
                    {
                        context.Tree.Remove(delNode);
                        context.SaveChanges();
                    }
                    else
                    {
                        result.ReturnResult = false;
                        result.ReturnMessage = "Cannot delete.";
                    }
                }
            }
            catch (Exception exc)
            {
                result.ReturnResult = false;
                result.ReturnMessage = exc.Message;
            }

            JavaScriptSerializer JSON = new JavaScriptSerializer();
            return JSON.Serialize(result);

        }

想法是显示提示,然后等待按下Enter键。