Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望我的程序创建一个位于命令参数路径的文件,即program /home/user/directory/that/doesnt/exist/file. 如果目录不存在,fopen将无法打开文件,因此程序必须创建目录。我是否必须编写自己的循环来检测每个斜杠和mkdir每个目录,或者是否有自动执行此操作的功能?
program /home/user/directory/that/doesnt/exist/file
fopen
mkdir
有人为你编码:mkpath()
或者,如果您对使用感到满意system(),那么您可以使用system("mkdir -p /your/path/here");
system()
system("mkdir -p /your/path/here");