malloc_error_break导致C ++ SIGABRT

时间:2009-09-28 16:43:02

标签: c++ file copy runtime

我的代码出了什么问题? (我试图至少在XCode(OS X 10.6 Snow Leopard)中使用此代码复制文件。) 我在运行时继续使用malloc_error获取SIGABRT:

Lesson 4(796) malloc: *** error for object 0x10000a8a0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

这是代码(main.cpp):

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

using namespace std;
void encrypt(char plainFile[], char cipherFile[], int key);
void decrypt(char cipherFile2[], char plainFile2[], int key);

void encrypt(char plainFile[], char cipherFile[], int key){
 ifstream fin;
 fin.open(plainFile);

 if (fin.fail()){ // check if "input.txt" is open
  cout << " ";
  exit(1);
 }

 ofstream fout(cipherFile);
 string outputStuff;
 fin >> outputStuff;
 fout << outputStuff;
 fin.close();
 fout.close();
}

void decrypt(char cipherFile2[], char plainFile2[], int key){
 }


int main (int argc, char * const argv[]) {

    encrypt("L04_plain1.txt", "cipher1.txt", 3);
 //decrypt("L04_cipher2.txt", "plain2.txt", 3);

 return 0;
}

我在Build文件夹和外部文件夹中都有所需的文件(“L04_plain1.txt”和“L04_cipher2.txt” - 包含项目文件和main.cpp的文件)。

请帮助!!!!!!

0 个答案:

没有答案