我尝试了很多事情,但都没有结果。我用过
<cstdio>
但没有帮助。
我再次尝试使用fget,但没有得到任何好的结果。我使用了在线编译器
http://rextester.com/l/cpp_online_compiler_gcc
#include <iostream>
#include <string.h>
#include<stdio.h>
#include<cstdio>
using namespace std;
int main() {
bool check;
char sntn[100],word[100],test[20];
gets (word);
gets (sntn);
int j=0,count=0,val,k;
check=true;
while(check) {
for(; sntn[j]==32; j++) {
test[k]=sntn[j];
k++;
}
}
k=0;
j+=1;
val=strcmp(test,word);
if(val==0)
count++;
if(sntn[j]==32) {
j+=1;
check=true;
}
if(sntn[j]=='\0')
check=false;
cout<<endl<<count;
return 0;
}
错误:
source_file.cpp: In function âint main()â:
source_file.cpp:9:11: error: âgetsâ was not declared in this scope
gets (word);
^