Dear all,
I can able to get the last line ten chars but i cant get if the last line is null.
here is my code
here with i have enclosed my file where i am pick my last ten chars kindly guide me...
thanks and regards,
Robert.J
I can able to get the last line ten chars but i cant get if the last line is null.
here is my code
Code:
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
ifstream SVfile("D:\\bys\\LOG.txt");
string sLine;
string SVcode;
getline(SVfile, sLine);
SVcode = sLine;
char temp[1000000];
ifstream file;
stringstream ss;
string value;
string SVfilename = SVcode;
string SVpath = "D:\\bys\\"+SVfilename;
const char * f = SVpath.c_str();
file.open(f);
while(!file.eof())
{
file.getline(temp,1000000);
}
ss << temp;
ss >> value;
string lastchar = value.substr(0,10);
// cout << lastchar << endl;
ofstream myfile;
string filename = lastchar+".txt";
string filepath = "D:\\bys\\"+filename;
const char * c = filepath.c_str();
myfile.open (c);
myfile << lastchar;
cout<<lastchar<<endl;
myfile.close();
system("PAUSE");
return EXIT_SUCCESS;
}
thanks and regards,
Robert.J
Comment