#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
int main()
{
FILE *frp = NULL;
char *ibuff=NULL;
char *obuff=NULL;
frp = fopen("./output_manname.txt", "r");
/*判断文件大小*/
fseek(frp, 0, SEEK_END);
unsigned long long malloc_size = ftell(frp);
printf("length is %ld\r\n", malloc_size);
fseek(frp, 0, SEEK_SET);
ibuff=(char*)malloc(malloc_size);
fread(ibuff,malloc_size,1,frp);
printf("%s\n", ibuff );
fclose(frp);
obuff=(char*)malloc(malloc_size);
/*嵌入换行\r(\r不要也可以)回车\n*/
char *itmp=ibuff;
char *otmp=obuff;
while(0!=*(itmp+1))
{
*otmp=*itmp;
if(0 != isupper(*itmp) && 0 != isupper(*(itmp+1)))
{
itmp++;
continue;
}
*otmp=*itmp;
itmp++;
otmp++;
}
printf("%s", obuff);
/*写入文件*/
FILE *fwp;
fwp = fopen("./output_manname_noAA.txt", "w+");
fwrite(obuff, malloc_size, 1, fwp);
printf("%s\n", obuff);
fclose(fwp);
free(ibuff);
free(obuff);
return 0;
}
[C]把一个字符文件的连续2个大写字母改成1个大写字母
最新推荐文章于 2021-09-20 01:40:32 发布