Why?
a hacker can replace the program (even the operating system ones) your program calls via system with malware of the same name. The odds of this are zero when its a personal utility program, but you cannot release a program out for others to use using this technique as the more popular it becomes, the more of a target it becomes, and its a security hazard.
that is on top of being unable to easily get errors back from it which was already stated, though you can redirect your commands to a text file and capture the output and work with it that way (clunky!).
in general, if the thing you are doing is trivial to do in standard c++, you should *learn* the c++ way and do it that way. If it is going to take a lot of code or a library, you can spawn a program (there are a half dozen ways to do that, exec, spawn, create process, system, fork, and more?) each with pros and cons.
the command you are doing is trivial in standard c++ using <filesystem> calls. Include it, look up what to do, and do that instead for this specific use case.
https://en.cppreference.com/w/cpp/filesystem/current_path