私のプログラムの目的は、ファイルからテキストを読み込んで別のテキストファイルにエンコードし、その中に文字をスクランブルので、文字列ではなく、別々にエンコードされた各単語が必要なので、後でこれを行うことができます。これまでのところ、私が持っている:fscanfを使ってテキストを読むfprintfを使ってテキストをファイルに出力する
#define INPUT_FILENAME ("A6P1_2016_TestingSherlock.txt")
#define OUTPUT_FILENAME ("EncodeMe.txt")
void process_file(FILE* ifp, FILE* ofp) {
printf("Begin file processing\n");
char word[100];
while(fscanf(ifp, "%s", word) != EOF){
fprintf(ofp, "%s ", word);
}
printf("End file processing\n");
}
を私は入力ファイルから取っているテキストは
Project Gutenberg The Adventures of Sherlock Holmes, by Arthur Conan Doyle
This eBook is for the use of anyone anywhere at no cost and with
almost no restrictions whatsoever. You may copy it, give it away or
re-use it under the terms of the Project Gutenberg License included
with this eBook or online at www.gutenberg.net
そしてEncodeMeテキストファイル内に以下のように、私はちょうど1行に印刷されたすべてのものを得ることです。助けてください?
は一度に行全体を読んで、そしてラインから個々の単語を取得するために 'strtok'を使用するために、' fgets'を使用したい場合。 – user3386109
@ user3121023おっと、私は文字列の代わりに、別々にエンコードされた各単語が必要だと言いました。以前は正確なコードを使用していましたが、単語を簡単に編集することはできません –