檔案I O 乙個小程式

2021-06-22 01:48:13 字數 663 閱讀 5232

編寫乙個檔案複製程式:

c語言版本:

#include

#include

int main( int argc,char *argv )

if( ( in = fopen( argv[1], "rb") ) == null )

if( ( out =fopen( argv[2],"wb" ) ) ==null )

while( ( ch = getc( in ) ) != eof ) 

}if( ferror( in ) )

if( ferror( out ) )

printf("成功複製1個檔案!\n");

fclose( in );

fclose( out );

return 0; }

編譯執行後,利用debug檔案中字尾為.exe檔案就可以實現檔案的複製功能。

c++版本:

#include

#include

using namespace std;

int main()

char x;//c++在任何地方都可以定義乙個變數,隨用隨定義

while( in>>x)

coutreturn 0; }

以上只是將檔案test中的字元在螢幕上顯示出來。

乙個java小程式

能讓阿拉伯數字讀成符合漢語語法和漢語習慣的中文.就這我 還做了一天呢 鬱悶.public class itcs string unit1 new string string unit2 new string string str args 0 string str 2 null system.out...

乙個socket小程式

一直對c c 下的socket程式設計必是很熟悉,今天終於完成了乙個很簡單的server client程式 伺服器 include include pragma ment lib,ws2 32.lib using namespace std const int my error 1 int main...

乙個日曆小程式

include define sunday 0 define monday 1 define tuesday 2 define wednesday 3 define thursday 4 define friday 5 define saturday 6 void giveinstructions ...