I have a list of files stored in a .txt file
$codeguru\c++\display.txt$15$
Directory File Folder: codeguru\c++
File Name: display.txt
File Size: 15kbs
$ is an delimiter
I want to extract the name and the extension from txt files. Can you give a example of a simple way to do this?
Code:#include <iostream> #include <fstream> #include <cstdlib> struct MyFile { std::string Directory; std::string Filename; unsigned filesize; }; int main() { std::ifstream readfile ( "mylog.txt"); if(!readfile) { std::cout << "Please check that the file exists" << std::endl; exit(1); } while (!readfile.eof()) { //string::find() // string::substring() // substr or find_last_of } // copy all the data to a new file and save it.. }




Reply With Quote