本文介绍了原生“退出与代码3(0x3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在调试此代码时遇到以下问题:
I have the following problem when I debug this code:
// 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;
}
产生此错误:
'Croppen.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Symbols loaded (source information stripped).
The program '[2884] Croppen.exe: Native' has exited with code 3 (0x3).
任何人都可以说我的问题在哪里?
Can any one say where my problem is?
我使用MS VS 2010 Prof IDE。
I use the MS VS 2010 Prof IDE.
推荐答案
do {
scanf("%s", eingabe);
} while ( getchar() != '\n');
不是文字逐字读取的幸运选择。你可以做(C风格法):
isn't a lucky choice for reading from file word by word. You could either do (C-style approach):
while (scanf("%s", eingabe) == 1) {
...
}
std :: string 和streams(C ++):
or use std::string
s and streams instead (C++):
std::string word;
while (std::cin >> word) {
...
}
虽然我想你只想在这种情况下读取一行文件名:
although I think you just want to read 1 line with a filename in this case:
std::string filename;
if (std::getline(std::cin, filename)) {
...
}
这篇关于原生“退出与代码3(0x3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!