close

參考文章:http://monkeycoding.com/?p=953

 

// file_open_test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream>
#include<fstream>
using namespace std; 

int _tmain(int argc, _TCHAR* argv[])
{

    ifstream fin;
    ofstream fout;
    fin.open("test1.txt");     
    //fout.open("test1.txt");   

    if(!fin){ 
        return 1; 
    } 

    char ch; 
    //用!fin.eof()來判斷,最後會多讀一次
    while(fin.peek()!=EOF) {   
        fin.get(ch);
        printf( "%c", ch );
        //fout.put(ch); 
    } 

    fin.close(); 
   // fout.close();

    system("pause");
    return 0;
}
arrow
arrow

    跪著讀 發表在 痞客邦 留言(0) 人氣()