//c++按行讀取
/*
* main.cc
*
* Created on: 2011-12-1
* Author: simondu
*/
#include "head.h"
using namespace std;
int main(int argc, char* argv[])
{
printf("Starting…… \n");
string file = argv[1];
string tmp;
ifstream fin(file.c_str());
while(getline(fin,tmp))
{
cout《tmp《endl;
}
printf("Ending…… \n");
return 0;
}
//寫文件
/*
* main.cc
*
* Created on: 2011-12-1
* Author: simondu
*/
#include "head.h"
using namespace std;
int main(int argc, char* argv[])
{
printf("Starting…… \n");
string file = argv[1];
string tmp;
ofstream fin(file.c_str());
if(fin.is_open())
{
fin《"hello\n";
fin《"world\n";
fin.close();
}
printf("Ending…… \n");
return 0;
}