[英]How to get the file path of a file in c(how to do this in windows)
我需要獲取我最近在 c 中創建的文件的文件路徑
FILE *pFile;
pFile=fopen("client.txt","w");//create and open file in write mode
現在如何獲取client.txt的文件路徑?
您需要當前工作目錄。 getcwd會為你做這件事。
這應該工作
#include <unistd.h>
#include <linux/limits.h>
char path[MAX_PATH + 1];
char *cwd = getcwd(path, MAX_PATH);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.