How to get the current working directory in C++

2 Answers

0 votes
#include <iostream>
#include <filesystem>

// C++17

namespace fs = std::filesystem;

int main() {
	auto path = fs::current_path();

	std::cout << path;
}


/*
run:

"D:\\CPP_Examples"

*/

 



answered Dec 24, 2024 by avibootz
0 votes
#include <iostream>
#include <filesystem>

// C++17

int main() {
	auto path = std::filesystem::current_path();

	std::cout << path;
}


/*
run:

"D:\\CPP_Examples"

*/

 



answered Dec 24, 2024 by avibootz

Related questions

2 answers 361 views
1 answer 141 views
1 answer 286 views
2 answers 213 views
1 answer 286 views
...