无法在Visual Studio 2013上运行C ++程序

时间:2015-01-07 23:56:28

标签: c++ visual-studio

每当我尝试为我的课程运行程序时,我都会看到错误信息

"无法启动程序' C:\ users \ user \ documents \ visual studio 2013 \ projects \ coursework \ debug \ ConsoleApplication1.exe'

系统无法找到指定的文件"

输出标签显示"

1> ------ Build build:Project:ConsoleApplication1,Configuration:Debug Win32 ------

1>链接:C:\ Users \ User \ documents \ visual studio 2013 \ Projects \ Coursework \ Debug \ ConsoleApplication1.exe找不到或不是由最后一个增量链接构建的;执行完整链接

1> ConsoleApplication1.vcxproj - > C:\ Users \ User \ documents \ visual studio 2013 \ Projects \ Coursework \ Debug \ ConsoleApplication1.exe

==========构建:1成功,0失败,0最新,0跳过========== "

程序构建成功但不会运行,我该怎么办?

编辑(应用程序代码):

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{
// Open the data file
ifstream inputFile;
inputFile.open("weir.txt");

if (inputFile.is_open())
{
    int numberOfReadings;
    float width;
    float floodHeight;

    // Read the values for number of readings, width and flood height
    inputFile >> numberOfReadings;
    inputFile >> width;
    inputFile >> floodHeight;

    // Use a loop to input the time, date and River height

    for (int i = 0; i< numberOfReadings; i++) {

        string time;
        string date;
        float riverHeight;
        float flowrate;

        // Read the data values to produce

        inputFile >> time;
        inputFile >> date;
        inputFile >> riverHeight;

        // Check if the river overflows
        if (riverHeight > floodHeight) {
            cout << "The river will flood" << endl;
        }
        else {
            cout << "The river will not flood" << endl;
        }

        // Calculate the flow rate

        flowrate = sqrt(9.81)*width*riverHeight*sqrt(riverHeight);


        // Display all results

        cout << "time : " << time << endl;
        cout << "date : " << date << endl;
        cout << "River height : " << riverHeight << endl;

        cout << "Flow rate : " << flowrate << endl << endl << endl;
    }

    // Close the data file


    inputFile.close();



    // If data file does not open then produce an error message
}

else {
    cout << "Error, the data file was not opened" << endl;
}

return 0;
}

1 个答案:

答案 0 :(得分:0)

你应该检查一下你的项目的特性,可能是&#34;输出路径&#34;您可以在配置属性&gt;下找到C / C ++&gt;输出文件以及启动.exe的路径。您通常会在配置属性&gt;下找到启动.exe的路径。调试