这是一段代码,我将带有空格的字符串从文本打印到另一个 txt 文件中。我有一个代码列表,我必须用正确的代码切换特定的字符串。代码在一个数组中。我无法使编码功能起作用。Fprintf 打印代码后跟基本字符串。我想跳过这些字符串。我只需要打印代码。我在哪里错过了什么?
int m;
file = fopen("input.txt", "r" );
while (fscanf(file, "%s", word) != EOF ) {
for (m=0; m<j; m++) {
if (strcmp(word, particularwords[m]) == 0) {
fprintf(outfile, "%s ", code[m]);
continue;
}
}
fprintf(outfile, "%s ", word);
}