それで、これがクラスの単純な部分のための私のコードです:
void ArrayToTextFile::textfiller(string *givenpointer){
cout<< "Recieved array pointer address" << givenpointer << endl;
const char * constantcharversion = path.c_str();
ofstream filler(constantcharversion);
int i = 0;
//string delims = (string)delim;
for(i = 0; i < sizeof(*givenpointer); i++) {
filler << *givenpointer << delim;
givenpointer = givenpointer + 1;
}
filler.close();
}
ポインタは、文字列の配列の最初の要素を指します。
delim
';'です
これは私のメインクラスです:
#include <iostream>
#include "ArrayToTextFile.h"
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main()
{
system("color 1A");
cout << "Hello world!" << endl;
string kinch[3] = {"a", "second el", "third"};
ArrayToTextFile newone("C:/haha.txt", ';');
string *pointy = &kinch[0];
newone.textfiller(pointy);
return 0;
}
プログラムが実行されるときはいつでも、returnステートメントに到達することはできません。実際、コンソールウィンドウの終了ボタンをクリックする必要があります。作成されたテキストファイルを見ると、それは巨大です。
私の問題は何ですか?どうすればこれを修正できますか?