Tom*_*mmy 3 c file-io fopen path
我正在使用,我需要打开一个文件,在其中fopen()
传递一个带有空格的路径作为参数。这是我的代码:
FILE * pFile;
pFile = fopen ("\this folder\myfile.txt","w");
Run Code Online (Sandbox Code Playgroud)
这样可以吗?还是我需要在其中添加一些内容来识别该空间?谢谢。
空间可以,但你需要逃离'\'
,因为
pFile = fopen ("\\this folder\\myfile.txt","w")
Run Code Online (Sandbox Code Playgroud)
如果路径中有空格,则无需执行任何特殊操作。
pFile = fopen ("\\this folder\\myfile.txt","w");
Run Code Online (Sandbox Code Playgroud)
应该管用。请注意字符串中所需的双反斜杠。
归档时间: |
|
查看次数: |
7560 次 |
最近记录: |