2013-10-09 1 views
0

나는이 코드를 디버깅 할 때 다음과 같은 문제가있다 :네이티브 코드 3 (은 0x3)으로 종료 된

// 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). 

어떤 사람은 말할 수 ?

나는 MS VS 2010 Prof IDE를 사용합니다.

+0

C 스타일의 문자열과 'fopen'과 같은 C 스타일의 함수를 사용하는 이유가 있습니까? – LihO

+0

'system ("exit")이란 무엇입니까? –

+0

예, 약 2000 년에 열리는 promam, 다른 E/A commandos를 닫으십시오. 가능한 경우 변경하지 마십시오. 시스템 ("출구"); 좋은 오래된 DOS를 사용하면 편리하게 프로그램을 닫을 수 있습니다. –

답변

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

은 단어 단위로 파일을 읽는 데있어서 행운의 선택이 아닙니다.

while (scanf("%s", eingabe) == 1) { 
    ... 
} 

또는 std::string의를 사용하는 대신 (C++) 스트림 : 당신은 (C-스타일의 접근 방식을) 할 수있는 하나 당신이 단지 파일 이름과 한 줄을 읽고 싶은 생각하지만

std::string word; 
while (std::cin >> word) { 
    ... 
} 

이 경우 :

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