| Код | #include "stdafx.h"
#include <fstream> #include <iostream> #include <string> #include <vector>
using namespace std;
void first_last(char *fn) { ifstream fi(fn); vector<string> vs; char s[256]; while (!fi.eof()) { fi.getline(s, 256); vs.push_back(s); } fi.close(); if (vs.size()>1) { string g=vs[0]; vs[0]=vs[vs.size()-1]; vs[vs.size()-1]=g; ofstream fo(fn); for (int i=0; i<vs.size(); i++) fo<<vs[i]<<endl; } }
int main() { char filename[]="D:\\1.txt"; first_last(filename); return 0; }
|
это в VS 2008 компилил, если у тебя что-то другое, то подрихтуй инклуды... |