码迷,mamicode.com
首页 > 其他好文 > 详细

注释转换

时间:2016-03-10 01:45:10      阅读:162      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!