當前位置:編程學習大全網 - 編程軟體 - 求教C語言編程啊 實現文本的選擇連接

求教C語言編程啊 實現文本的選擇連接

/*

本程序由Turbo C2.0編譯通過。文本文件1.txt請放在Turbo C所在目錄下。則輸出文件1.txt也在Turbo C所在目錄下。

*/

#include "stdio.h"

main()

{

FILE *fp,*temp;

char ch;

int i=0;

clrscr();

if(((fp=fopen("1.txt","r+"))&&(temp=fopen("1.tmp","w+")))==NULL)

{

printf("Can't open file\n");

printf("Press any key to exit...");

getch();

exit(0);

}

printf("\nPlease wait...");

while(!feof(fp))

{

fputc(fgetc(fp),temp);

i++;

if(i%200==0) fputc('\n',temp);

}

rewind(temp);

fputc('\n',fp);

fputc('\n',fp);

while(!feof(temp)) fputc(fgetc(temp),fp);

fopen("1.tmp","w");

fclose(fp);

fclose(temp);

printf("OK!\n");

printf("Press any key to exit...");

getch();

printf("Bye bye!");

exit(0);

}

附:讀取文本文件

cha dat[20];

FILE *fp;

fp=fopen("man.txt","rb");

fread(dat, sizeof(char), 20, fp);

int a=strchr(dat,'@');

  • 上一篇:優秀的小學語文flash課件該怎樣設計 網上的壹些flash課件要不就是壹個動畫,要不就是跟ppt類似的課文朗讀
  • 下一篇:單片機流水燈匯編程序
  • copyright 2024編程學習大全網