标签:c注释转换
#include <stdio.h> #include <stdlib.h> #include <string.h> //#if(1) int main() { FILE *fin,*fout; char str1[81],str2[81]; //假定每行不超过80个字符 char *infile = "in.c"; char *outfile = "out. char *p; fin = fopen(infile,"r"); // 读格式打开,默认为文本类型 fout = fopen(outfile,"w"); // 写格式打开,默认为文本类型 if((fin == NULL) || (fout == NULL)) { printf("打开文件失败!\n"); exit(1); } // while(fscanf(fin,"%s",str1) == 1) while( fgets(str1,50,fin)) { // 在这儿处理串str1...... p=strstr(str1,"//"); if(p==NULL) strcpy(str2,str1); else { strncpy(p,"/*",2); strcat(str1,"*/"); strcpy(str2,str1);} fprintf(fout,"%s",str2); // 写入文件 fprintf(fout,"\n"); } fclose(fin); fclose(fout); return 0; } //#endif #if(0) void main() { char a[10] = {0}; int i=0,N=10; while(fgets(a, N, stdin)) { fprintf(stdout, "%d %s@%d\n", i, a, strlen(a)); i++; } } #endif
标签:c注释转换
原文地址:http://sts609.blog.51cto.com/11227442/1749387