不支持中文!!!有没有兴趣学下C!- //Dec-C++ 5.11
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
-
- int max=10240;
-
- FILE *fp(char *p_n,const char *mode);
- char *analyze(char *a);
-
- int main(int argc,char *argv[] )
- {
- FILE *s_txt;
- FILE *res_txt;
- s_txt=(fp(argv[1],"r"));
- res_txt=(fp(argv[2],"w"));
- char arr[max]="0";
- char *p=arr;
- char temp[max]="0";
- int i;
- while (fgets(temp,max,s_txt)!=NULL)
- {
- p=analyze(temp);
- fprintf(res_txt,"%s",p);
- }
- fclose(s_txt);
- fclose(res_txt);
- return 0;
- }
- FILE *fp(char *p_n,const char *mode)
- {
- FILE *fp;
- if ((fp = fopen(p_n,mode)) == NULL)
- {
- printf("%s open fail!!",p_n);
- getchar();
- exit(0);
- }
- return fp;
- }
-
- char *analyze(char *a)
- {
- static char res[1024]="0";
- char *p=res;
- if (a[0]=='#')
- {
- strcpy(res,a);
- return p;
- }
- char del='/';
- int i,j=0;
- for (i=0;a[i]!='\0';i++)
- {
- if (a[i]==del) j=0;
- if (a[i]!='?' && a[i]!=del)
- {
- *(p+j)=a[i];
- j++;
- }
- else if (a[i]=='?')
- {
- *(p+j)='\n';
- *(p+j+1)='\0';
- return p;
- }
-
- }
- strcpy(res,a);
- return p;
-
- }
复制代码
|