提交记录 #334
提交时间:2024-11-26 23:19:32
语言:c
状态:CompileError
编译情况:编译错误
code.c: In function ‘main’:
code.c:10:5: warning: implicit declaration of function ‘fgets’ [-Wimplicit-function-declaration]
10 | fgets(p, 200, stdin);
| ^~~~~
code.c:10:19: error: ‘stdin’ undeclared (first use in this function)
10 | fgets(p, 200, stdin);
| ^~~~~
code.c:5:1: note: ‘stdin’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’?
4 | #include <ctype.h>
+++ |+#include <stdio.h>
5 | int main(){
code.c:10:19: note: each undeclared identifier is reported only once for each function it appears in
10 | fgets(p, 200, stdin);
| ^~~~~
code.c:23:17: warning: implicit declaration of function ‘putchar’ [-Wimplicit-function-declaration]
23 | putchar(*(excg+q));
| ^~~~~~~
code.c:32:5: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
32 | printf("\n");
| ^~~~~~
code.c:32:5: warning: incompatible implicit declaration of built-in function ‘printf’
code.c:32:5: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
固定测试点暂不可用
附加测试点暂不可用
52【字符】字符替换*——用指针更方便
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(){
char *p = malloc(sizeof(char) * 200 );
char *index = malloc(sizeof(char) * 20 );
char *excg = malloc(sizeof(char) * 20 );
int i, j=0;
fgets(p, 200, stdin);
fgets(index, 20, stdin);
while(1==1){
if(*(index+j)=='\n'){
*(index+j)='\0';
break;
}
j++;
}
fgets(excg, 20, stdin);
for(i=0; *(p+i)!='\n';){
if( (p+i)==strstr(p, index)){
for(int q=0; *(excg+q)!='\n'; q++){
putchar(*(excg+q));
}
i=i+strlen(index);
}
else{
putchar(*(p+i));
i++;
}
}
printf("\n");
return 0;
}