天天看點

使用 ./a.out > log.txt 将log寫入檔案

       本文來說個小技巧:

#include <iostream>
using namespace std;

int main()
{
	cout << "hello world" << endl;

	return 0;
}           

      不改代碼, 怎麼把上述log導入到檔案呢? 簡單搞起:

xxxxxx:~> g++ test.cpp
xxxxxx:~> ./a.out > a.txt
xxxxxx:~> cat a.txt
hello world
xxxxxx:~>            

       不多說。

繼續閱讀