私が欲しいのは、txtファイルを読み取り、各行を配列に入れてから、複製コピーを別のtxtファイルに出力するc++プログラムです。これが私のコードです...
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
string STRING ="";
string list[10000];
int i = 0;
ifstream infile;
infile.open ("C:/Users/Ryan/Desktop/data.txt");
ofstream myfile;
myfile.open ("C:/Users/Ryan/Desktop/data-2.txt");
while(!infile.eof()) // To get you all the lines.
{
getline(infile,STRING);
list[i]=STRING;
myfile<<list[i];
++i;
}
infile.close();
myfile.close();
return 0;
}
どういうわけか、これをやっているのに、1行おきにファンキーな漢字がたくさん出てきます。これが私のdata.txtです...
BPC 20101206 V 0.13 0.13 0.13 0
BPC 20101207 V 0.13 0.13 0.13 6500
BPC 20101208 V 0.13 0.13 0.13 0
BPC 20101209 V 0.13 0.125 0.125 117000
BPC 20101210 V 0.125 0.125 0.125 0
BPC 20101213 V 0.125 0.125 0.125 0
BPC 20101214 V 0.13 0.13 0.13 5000
BPC 20101215 V 0.13 0.13 0.13 290
BPC 20101216 V 0.125 0.115 0.115 24000
そして、これが出力データです-2.txt ...
BPC 20101206 V 0.13 0.13 0.13 0
䈀倀䌀ऀ㈀ ㈀ 㜀ऀ嘀ऀ ⸀㌀ऀ ⸀㌀ऀ ⸀㌀ऀ㘀㔀 ഀ BPC 20101208 V 0.13 0.13 0.13 0
䈀倀䌀ऀ㈀ ㈀ 㤀ऀ嘀ऀ ⸀㌀ऀ ⸀㈀㔀ऀ ⸀㈀㔀ऀ㜀 ഀ BPC 20101210 V 0.125 0.125 0.125 0
䈀倀䌀ऀ㈀ ㈀㌀ऀ嘀ऀ ⸀㈀㔀ऀ ⸀㈀㔀ऀ ⸀㈀㔀ऀ ഀ BPC 20101214 V 0.13 0.13 0.13 5000
䈀倀䌀ऀ㈀ ㈀㔀ऀ嘀ऀ ⸀㌀ऀ ⸀㌀ऀ ⸀㌀ऀ㈀㤀 ഀ BPC 20101216 V 0.125 0.115 0.115 24000
何か案は?