c語言程序設計txt
A. 《c語言程序設計》電子書下載!!TXT格式的誰有,感激不盡
網路文庫,寫上譚浩強
我下的是ppt格式的,手機看的
C和C++都看了,不是很好
不如看C程序設計語言,可惜我也沒找到電子版的
只是看到了C prime而已,也不錯
B. c語言程序設計 將數據寫入指定的txt文件
1.
需要操作制定的文件,首先需要獲取文件的文件描述符(句柄):fd
=
fopen("test.txt","w")
2.
使用fprintf(),或者fputs()函數將數據格式化寫入該文本
#include
main()
{
FILE *f;
f=fopen("wenzhang.txt","w");
fprintf(f,"this is a c program !");
fclose(f);
}
C. 如何用c語言編程實現txt文件中的查找與替換功能希望能有完整過程
#include<stdio.h>#include<stdlib.h>//By cockhorseman QQ:1004828288void main(){ FILE *p; char a[200],c,b,i; if((p=fopen("zifu","r"))==0)//打開文件 {printf("文件打開失敗!\n");}else{fscanf(p,"%s",a);printf("你要替換的字元\n");c=getchar();getchar(); //結束接收第一個字元printf("你要替換成的字元\n");b=getchar(); for(i=0;a[i]!=0;i++)//實現替換{if(a[i]==c)a[i]=b;}printf("%s\n",a);fprintf(p,"%s",a);//文件輸出fclose(p);} }
D. 《C語言程序設計第四版》pdf下載在線閱讀全文,求百度網盤雲資源
《C語言程序設計第四版》網路網盤pdf最新全集下載:
鏈接: https://pan..com/s/1OJyaV3BLbsB8eBo8cUAvBQ
簡介:《C程序設計(第四版)》是由譚浩強編著,2010年清華大學出版社出版的中國高等院校計算機基礎教育課程體系規劃教材。該書可作為高等學校各專業的正式教材,也是一本自學的教材
E. c語言程序設計 TXT分類版
是TXT分割嗎,我自己編了一個C程序:
#include<stdio.h>
//#include<lib.h>
#include<conio.h>
#include<string.h>
intpart_num[9999]={0};
charnewname[8]="";
charp[8]={0,0,0,0,0,0,0,0};
voidtxt_wrte();
voidint2str(intx);
voidnum2str(intx,intn,charp[8]);
main()
{
FILE*fp;//文件指針fp
intBytenum=0,Bytenum2=0;
intpnum=0;
intpnum_p_part;
inttemp,i;
charch,key;
//charstr[65536];
charffilename;
char*filename;//="sq3.txt";
char*pachname=".\";
char*endname=".txt";
charfhead[32]="";
charfullname[32]="";
charfiletemp[17]="";
intszname;
printf("輸入文件名 ");
printf("Inputfilename: ");
//scanf("%s",&filename);//輸入文件名
for(temp=0;temp<16;temp++)
{
key=getchar();
if(key==' ')
{break;}
filetemp[temp]=key;
//filename++;
}
printf("---------- ");
filename=&filetemp;
printf("---------- ");
strcpy(fullname,pachname);//路徑以及文件名拼接
strcat(fullname,filename);
strcpy(fhead,fullname);
strcat(fullname,endname);
printf("%s ",fullname);
//fullname=strcat(pachname,filename);
if((fp=fopen(fullname,"rt"))==NULL)
{
printf("can'topen");
getch();
exit(1);
}
else
{
printf("opensucsessfuly! ");
}
//---------------------------------
ch=fgetc(fp);
while(ch!=EOF)
{
//putch(ch);
ch=fgetc(fp);
if(ch==' ')
{
pnum++;
}
//pnum*20000/(Bytenum)
Bytenum++;
}
printf(" 該文件一共有%dB(位元組),%d個段落. ",Bytenum,pnum);
//printf("大約每%d段有20KB. ",pnum/(Bytenum/20000));//must>=20kB
printf("大約每%d段有20KB. ",pnum*20000/(Bytenum));
printf("分割成每個文件的段落數為:");
scanf("%d",&pnum_p_part);
printf("大約會有%d個文件生成. ",pnum/pnum_p_part);
//----------------------------
rewind(fp);
ch=fgetc(fp);
temp=0;i=0;
Bytenum2=0;
while(ch!=EOF)
{
ch=fgetc(fp);
if(ch==' ')
{
temp++;//' '的個數
if(temp%pnum_p_part==0)
{
part_num[i+1]=Bytenum2;//記錄 的位置
//printf(" enter:%d ",part_num[i]);
i++;
}
}
Bytenum2++;
if(ch==EOF)part_num[i]=Bytenum2;
}
//---------------------------------------
//for(i=0;i<(pnum/pnum_p_part+1);i++)
//{
//printf(" enter:%d ",part_num[i]);
//}
//-----------------------------------------
printf("---------- ");
printf("---------- ");
txt_wrte(filename,pnum/pnum_p_part,fp,part_num);
//fgets(str,i,fp);
fclose(fp);
while(!kbhit());
}
voidtxt_wrte(char*filename,inttotalpartnum,FILE*fp,intpart_num[9999])
{
FILE*fp_pic;
inti,j;
intstr_len;
charch_temp;
rewind(fp);
//fseek(fp,part_num[i],0);
mkdir(".\new");
//num2str(totalpartnum,4,p);
int2str(p,totalpartnum);
printf("%s ",p);
strcpy(newname,".\new\");
strcat(newname,filename);
strcat(newname,"_");
strcat(newname,p);
//strcat(newname,".txt");
//printf("%s ",newname);
str_len=strlen(newname);
for(i=0;i<totalpartnum;i++)//批量生成文件
{
//printf("%s ",p);
//strcpy(newname,".\new\");
strcat(newname,filename);
strcat(newname,"_");
for(j=0;j<8;j++)p[j]=0;
//for(j=0;j<8;j++)newname[j]=0;//clearspace
strcpy(newname,"");
int2str(p,i);
strcpy(newname,".\new\");
//strcat(newname,filename);
strcat(newname,p);
strcat(newname,".txt");
printf("%s ",newname);
if((fp_pic=fopen(newname,"wt"))==NULL)
{
printf("can'topen");
getch();
exit(1);
}
else
{
printf("opensucsessfuly! ");
for(j=0;j<(part_num[i+1]-part_num[i]);j++)//writebyte
{
ch_temp=fgetc(fp);
fputc(ch_temp,fp_pic);
}
}
fclose(fp_pic);
}
}
/*voidnum2str(intx,intn,charp[8])
{
//char*pp=p[0];
staticcharnum_str[11]={"0123456789"};
if(n==1)
{p[0]=num_str[x%10];}
elseif(n==2)
{
p[0]=num_str[(x%100)/10];
p[1]=num_str[x%10];
}
elseif(n==3)
{
p[0]=num_str[(x%1000)/100];
p[1]=num_str[(x%100)/10];
p[2]=num_str[x%10];
}
elseif(n==4)
{
p[0]=num_str[(x%10000)/1000];
p[1]=num_str[(x%1000)/100];
p[2]=num_str[(x%100)/10];
p[3]=num_str[x%10];
}
else
exit(1);
//printf("%c%c%c%c ",p[0],p[1],p[2],p[3]);
//returnpp;
}*/
voidint2str(charp[8],intx)
{
//static
//chartempre[5]="";
p[0]=(x%10000)/1000+48;
p[1]=(x%1000)/100+48;
p[2]=(x%100)/10+48;
p[3]=x%10+48;
p[4]='