繁体   English   中英

Visual Studio控制台应用程序调试

[英]Visual Studio console application debugging

我正在尝试使用Visual Studio构建行程计划控制台应用程序。

这是我的代码:

#include <fstream>
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

//Declaring variables
string userInput, userDest, userTime, userChange, y_cityName, a_tCityName, a_cityName;
int userIput, yChange, yLeg, _yLeg, aChange, aLeg, tChange, tLeg, _tLeg, a_tLeg;
int iUserTime, iUserMins, iUserHours, iUserChange;
ifstream inFile;
int journeyPlan();

//Function for handling outputting input.txt
int destinations(){
    //Clears Screen
    system("cls");

    //Clears string
    userInput = "";

    //Outputs the contents of input.txt
    cout << y_cityName << endl;
    cout << yChange << endl;
    cout << yLeg << endl;
    cout << _yLeg << endl;
    cout << "" << endl;
    cout << a_cityName << endl;
    cout << aChange << endl;
    cout << aLeg << endl;
    cout << "" << endl;
    cout << a_tCityName << endl;
    cout << tChange << endl;
    cout << tLeg << endl;
    cout << _tLeg << endl;
    cout << a_tLeg << endl;
    cout << "" << endl;
    cout << "2: View Journey Planner ";
    getline(cin, userInput);

    if (userInput == "2"){

        journeyPlan();

    }

    system("PAUSE");
    return 0;
}


//Function for checking userinput with inputs.txt
int journeyPlan(){

    //clears the screen
    system("cls");
    userInput = "";

    //stores userinputs within variables
    cout << "Specify time (HH:MM): ";
    getline(cin, userTime);
    cout << "Specify Destination: ";
    getline(cin, userDest);
    cout << "Specify Max Changes: ";
    getline(cin, userChange);

    //creating substrings and converting them to integers
    iUserHours = stoi(userTime.substr(0, 2));
    iUserMins = stoi(userTime.substr(3, 5));
    iUserChange = stoi(userChange);
    //calculation for coverting HH:MM to just minutes
    iUserTime = ((iUserHours * 60) + iUserMins);

    //performs check for to see if the user has asked for York, including time and changes
    if (userDest == y_cityName || userDest == "york"){
        if (iUserTime >= (yLeg + _yLeg)){
            if (iUserChange >= yChange){
                cout << "Time: " << userTime << " Change: " << yChange << " = " << "Suitable" << endl;
                //allows the user to go back and view destinations
            }
            else{
                cout << "Time: " << userTime << " Change: " << yChange << " = " << "UnSuitable" << endl;
            }
        }
        else{
            cout << "Time: " << userTime << " Change: " << yChange << " = " << "UnSuitable" << endl;
        }
    }
    else{
        cout << "There is no match for: " << userDest << endl;

    }

    //allows the user to go back and view destinations
    cout << "" << endl;
    cout << "1: View Journeys ";
    getline(cin, userInput);

    //checks userInput and sends them to destinations
    if (userInput == "1"){

        destinations();

    }
    system("PAUSE");
    return 0;
}

int menu(){

    system("cls");
    cout << " -- MAIN MENU -- " << endl;
    cout << "1 : Display Journeys" << endl;
    cout << "2 : Identify Suitable Journeys" << endl;
    cout << "Q : Quit" << endl;
    cout << "Pick: ";
    getline(cin, userInput);
    userIput = stoi(userInput);

    if (userIput == 1){
        destinations();
    }

    if (userIput == 2){
        journeyPlan();
    }

    if (userInput == "Q" || userInput == "q"){
        exit(1);
    }
    system("PAUSE");
    return 0;
}

int main(){
    system("cls");

    //Opens file input.txt
    inFile.open("input.txt");

    if (inFile.fail())
    {
        cerr << "Error opening file" << endl;
        exit(1);
    }

    //Reads text from file and stores them within variables
    inFile >> y_cityName >> yChange >> yLeg >> _yLeg >> a_cityName >> aChange >> aLeg >> a_tCityName >> tChange >> tLeg >> _tLeg >> a_tLeg;

    //Closing the file
    inFile.close();

    menu();
    system("PAUSE");
    return 0;
}

因此,当我按“本地Windows调试器”时,控制台会短暂闪烁,然后显示以下错误消息:

'ConsoleApplication1.exe' (Win32): Loaded 'C:\Users\JJH\Documents\Visual Studio 2013\Projects\ConsoleApplication1\Debug\ConsoleApplication1.exe'. Symbols loaded.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Cannot find or open the PDB file.
'ConsoleApplication1.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr120d.dll'. Cannot find or open the PDB file.
The thread 0x2358 has exited with code 1 (0x1).
The thread 0x518 has exited with code 1 (0x1).
The thread 0x136c has exited with code 1 (0x1).
The program '[2780] ConsoleApplication1.exe' has exited with code 1 (0x1).

因此,当然,我需要控制台保持打开状态才能使用该应用程序。

非常感谢您提供的任何帮助。

您运行的命令意味着:

您正在寻找:

  1. 在调试器下启动应用程序。
  2. 等待

您可以通过以下方式找到它:

  1. 打开“调试”菜单
  2. 选择“进入”菜单选项

有关更多详细信息,我建议阅读: Visual Studio调试器入门

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM