方法一:当前工程下的文件
fopen("demo.txt","rt")
方法二:当前工程下的 test文件夹 中文件
fopen(".\\test\\demo.txt","rt")
方法三:绝对路径,D盘下project文件夹中的文件
fopen("d:\\project\\demo.txt","rt")
用new或者mallocchar *fnasb(char *fn)
{
char *path_name = (char *)malloc(300)
strcpy(path_name, "E:\\cj\\")
strcat(path_name, fn)
return path_name
}
注:别忘记要free,tnasb同理