ファイルから文字を読み込んで文字配列に格納し、新しいファイルですが、すべての文字の生の数字が1つ増えています(ほとんどの経験豊富なプログラマーが私の話を知っています)。だから私は基本的に私自身の暗号化アルゴリズムを作ろうとしている。しかし、私は非常に奇妙なエラーが発生します: <various paths here>\main.cpp|27|error: no match for 'operator<<' (operand types are 'std::ifstream {aka std::basic_ifstream<char>}' and 'char')|
私はこのエラーについて多くのことを聞いたことがありますが、私が見ているのは、人々がクラス定義の関数を使用したときに起こることです。ソースコードは以下の通りです <various paths here>\main.cpp|27|note: no known conversion for argument 1 from 'std::ifstream {aka std::basic_ifstream<char>}' to 'int'|
:fstreamを使用してファイルに文字を書き込もうとしました: 'operator <<'と一致しません
#include <iostream>
#include <fstream>
using namespace std;
int main() {
int array_size = 1024000;
char Str[array_size];
int position = 0;
long double fsize = position;
ifstream finput("in.txt");
ifstream foutput("out.txt");
if(finput.is_open()) {
cout << "File Opened successfully. Storing file data into array." << endl;
while(!finput.eof() && position < array_size) {
finput.get(Str[position]);
position++;
fsize = position;
cout << "Processed data: " << fsize/1000 << "KB" << endl;
}
Str[position-1] = '\0';
cout << "Storing done, encoding..." << endl << endl;
for(int i = 0; Str[i] != '\0'; i++) {
cout << Str[i] << "changed to " << char(Str[i] + 1) << endl;
foutput << Str[i] += 1;
}
} else {
cout << "File could not be opened. File must be named in.txt and must not be in use by another program." << endl;
}
return 0;
}
注:私は(出力文字列にfstreamのではなく使用されている また、このエラーは、私は、人々はそれが便利な私を助けるために見つけるかもしれないと思うのノートに付属していますキャラクター、これを覚えておいてください)。