如何在PC中的特定位置使用C++创建文件

use*_*240 0 c++ file

嘿所有,我有一个问题,我不知道如何在PC中的特定位置用C++创建文件.例如,C:\ file.txt中的文件(.txt).有谁能够帮我?谢谢 :)

dir*_*tly 6

#include <iostream>
#include <fstream>
using namespace std;
int main() {
  ofstream ofs("c:\\file.txt");
  if (ofs) {
     ofs << "hello, world!\n";
  }
  return 0;
}
Run Code Online (Sandbox Code Playgroud)