C++ 本地';已退出,代码为3(0x3)

C++ 本地';已退出,代码为3(0x3),c++,visual-c++,runtime-error,visual-studio-debugging,C++,Visual C++,Runtime Error,Visual Studio Debugging,调试此代码时出现以下问题: // Croppen.cpp : Defines the entry point for the console application. #include "stdafx.h" #include "stdlib.h" int i,j,c; char hex[] = {"header.hex"}, ziel[] = {"ergebniss.bmp"}, eingabe[100]; FILE *f,*h; int _tmain(int arg

调试此代码时出现以下问题:

// Croppen.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include "stdlib.h" 

int i,j,c;
char hex[] = {"header.hex"},
     ziel[] = {"ergebniss.bmp"},
     eingabe[100];
FILE *f,*h;

int _tmain(int argc, _TCHAR* argv[])
{
    {//eingabe des Orginalen Bildnamens
        printf("Bitte geben sie den Bild namen ein. Maxiaml 20 Zeichen, mit '.bmp'\n");

        do { scanf("%s", eingabe); } while ( getchar() != '\n' );

        if ((f = fopen(eingabe,"rb")) == NULL)
        {
            printf("Fehler beim Öffnen von %s\n",eingabe);
            system("exit");
        }
    }

    {//header einlesen
        h = fopen(hex,"wb");
        for (i = 0; i < 52; i++) { putc(getc(f),h); }
    }

    return 0;
}
有人能说出我的问题在哪里吗

我使用MS VS 2010 Prof IDE

do {
    scanf("%s", eingabe);
} while ( getchar() != '\n');
逐字读取文件不是一个幸运的选择。您可以这样做(C型方法):

或者改用
std::string
s和streams(C++):

虽然我认为在这种情况下,您只需要读取一行文件名:

std::string filename;
if (std::getline(std::cin, filename)) {
    ...
}

你为什么要使用C风格的字符串和C风格的函数,比如
fopen
?什么是
系统(“退出”)
?是的,这是一个CA2000打开的promam,关闭其他E/a突击队,如果可能的话,我不想更改它们。系统(“退出”);来吧,这是一个很好的老DOS,它很容易关闭程序。如果不关闭程序,则必须使用exit()。退出代码往往与异常退出时的操作系统错误代码相匹配,3=“未找到路径”。太巧合了。
while (scanf("%s", eingabe) == 1) {
    ...
}
std::string word;
while (std::cin >> word) {
    ...
}
std::string filename;
if (std::getline(std::cin, filename)) {
    ...
}