root file directory.
how do i make my c++ program find the root of a file "username.txt" for example
check out boost::filesystem.
I believe the syntax is something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
#include <boost/filesystem.hpp>
#include <iostream>
namespace fs = boost::filesystem;
int main()
{
fs::path MyPath("username.txt");
std::cout << MyPath.leaf() << std::endl;
std::cout << MyPath.filename() << std::endl;
std::cout << MyPath.extension() << std::endl;
std::cout << MyPath.stem() << std::endl;
return 0;
}
|
"username.txt"
"username.txt"
".txt"
"username"
Press any key to continue . . . |
Last edited on
Topic archived. No new replies allowed.