ベクトル配列を ofstream ファイルに書き込んでいますが、特定の値が書き込まれません。IE:
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
int main (){
char * hold = new char [100];
vector<double> fx(2049);
ifstream inputFile;
ofstream myFile;
inputFile.open("data.txt");
myFile.open("test.txt");
for (int c=0; c<2049; c++){
inputFile.getline(hold, 100);
fx[c] = atof(hold);
}
for (int c=0; c<2049; c++){
myFile << fx[c] << "\n";
}
}
fx 内では、後半はすべて 0 です (fx[1024] から fx[2048]==0)。ただし、test.txt 内では、これらの 0 値は存在せず、キャリッジ リターンが適用されます。何かご意見は?ありがとう!(これらの質問の形式は初めてです...これをより理解しやすくするためのヒントをいただければ幸いです。)
注: このプログラムはかなり冗長であることを認識しています。実際のプログラムにはさらに多くの機能がありますが、これは単に正しく機能していない領域です。