#include
#include
#include
#define len 40
int main(void)
//開啟檔案並輸入內容
if((in=fopen(name,「w」))==null)
printf(「請輸入檔案內容:\n」);
while((ch=getc(stdin))!=eof)
putc(ch,in);
if(fclose(in)!=0)
fprintf(stderr,「error in closing file\n」);
//以上相當於為程式13.2提供的命令列引數,下邊是程式原文
//設定輸入
if((in=fopen(name,「r」))==null)
//設定輸出
strcat(name,".red"); //檔名後新增.red
if((out=fopen(name,"w"))==null)
//拷貝資料
while((ch=getc(in))!=eof)
if(count++ % 3 ==0)
putc(ch,out); //列印3個字元中的第乙個字元
//收尾工作
if(fclose(in)!=0||fclose(out)!=0)
fprintf(stderr, "error in closing files\n");
return 0;
C Primer Plus 第十三章筆記
1.使用公有派生,基類的公有成員將成為派生類的共有成員 基類的私有部分也將成為派生類的一部分,但只能通過基類的公有和保護方法訪問。2.派生類建構函式必須使用基類建構函式,意味著基類物件應當在程式進入派生類建構函式之前被建立。如果不呼叫基類建構函式,程式將使用預設的基類建構函式。3.可將派生類物件和位...
c primer plus 第十三章課後程式設計7題
a 交替列印倆個檔案的每一行 include include int main int argc,const char ar if fc fopen ar 2 r null 如果第乙個檔案遇到換行符則列印第二個檔案內容,反之一樣 a 交替列印倆個檔案的每一行。利用檔案指標的特性自動遞增的特點 do ...
c primer plus 第十三章課後程式設計9題
修改程式13.3 在單詞前邊從1開始為單詞編號,程式下次執行時新增新單詞,編號接上次的編號開始 include include include define max 41 int main void puts enter words to add to the file press the puts...