0
現在、sfml .loadfrommemoryメソッドを使用しようとしています。バイト配列としてファイルをテキストファイルに保存する方法は? C++
私の問題は、ファイルへのバイト配列としての仕組みがわかりません。 私は何かをコーディングしようとしましたが、ファイル全体を読み取るわけではありません。 は本当のサイズのファイルではありません。しかし、なぜ私は考えがありません。
using namespace std;
if (argc != 2)
return 1;
string inFileName(argv[1]);
string outFileName(inFileName + "Array.txt");
ifstream in(inFileName.c_str());
if (!in)
return 2;
ofstream out(outFileName.c_str());
if (!out)
return 3;
int c(in.get());
out << "static Byte const inFileName[] = { \n";
int i = 0;
while (!in.eof())
{
i++;
out << hex << "0x" << c << ", ";
c = in.get();
if (i == 10) {
i = 0;
out << "\n";
}
}
out << " };\n";
out << "int t_size = " << in.tellg();
は、Windows上で実行していますか?どのくらいのファイルが読み込まれませんか? '\ r '文字が飲み込まれている可能性はありますか? –
@Martin:IIRCでは、EOF文字(26)も、テキストモードではifstreamに影響します。 –
@BenVoigt - 実際、彼はそうではありません。 'c'の定義(配列の先頭を書く前)は' in.get() 'を呼び出します。 –