わびさびサンプルソース

WindowsやHTML5などのプログラムのサンプルコードやフリーソフトを提供します。

ファイルの読み込み(1文字取得)

get()関数はファイルから一文字取得します。

#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <fstream>



/*
	ファイルの読み込み
*/
int _tmain
(
	  int argc
	, _TCHAR* argv[]
)
{
	// 標準出力にユニコード出力する
	setlocale( LC_ALL, "Japanese" );

	std::ifstream ifstr( L"file.txt" );
	char ch;

	// 1文字ずつ最後まで読み込み
	while( ifstr.get( ch ) ) std::cout << ch;

	// 正常終了
	return( 0 );
}

実行結果

ファイル内容です






わびさびサンプルソース

WindowsやHTML5などのプログラムのサンプルコードやフリーソフトを提供します。