Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C fprintf编码字符串跳过_C_Scanf_Printf - Fatal编程技术网

C fprintf编码字符串跳过

C fprintf编码字符串跳过,c,scanf,printf,C,Scanf,Printf,下面是一段代码,我将文本中带有空格的字符串打印到另一个txt文件中。我有一个代码列表,我必须用正确的代码切换特定的字符串。代码在一个数组中。我无法使编码功能工作。Fprintf打印后跟基字符串的代码。我想跳过这些字符串。我只需要把密码打印出来。我在哪里错过了什么 int m; file = fopen("input.txt", "r" ); while (fscanf(file, "%s", word) != EOF ) { for (m=0; m<j; m++)

下面是一段代码,我将文本中带有空格的字符串打印到另一个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);
}
intm;
file=fopen(“input.txt”,“r”);
而(fscanf(文件,“%s”,word)!=EOF){

对于(m=0;m而言,继续是问题所在

它将继续for循环,而不是while循环

我认为应该是这样的:

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]);
            break; //for                     
        }
    }
    if(m==j){ //word not found!
       fprintf(outfile, "%s ", word);
    }
}
intm;
file=fopen(“input.txt”,“r”);
而(fscanf(文件,“%s”,word)!=EOF){

对于(m=0;mDon),请不要使用(
f
scanf
读取字符串(但如果必须,请指定长度)。请改用。您的“代码”是否包含其他
%
符号?不,它只包含英文字母表中的小写字符,但nvm已解决!!!