fopen("abc.txt" "w"); 文件建在哪儿的有关问题

fopen("abc.txt", "w"); 文件建在哪儿的问题
	FILE* logfile = fopen("abc.txt", "w");
fclose(logfile);

之前一直这样用Windows上、linux上,abc.txt都是建在生成的可执行程序文件夹(dev-c是这样.VS生成到项目所在文件夹,但也差不多).

因为C标准里没有写这个函数不写路径的时候建在哪,所以我一直觉得是操作系统决定的.

后来我用codeblocks,这样写就建在了C盘根目录下.

我想知道,像这种函数,最终决定生成文件建在哪,是谁决定的?是编译器?还是编译器选项?,比如编译器可以设置一些环境变量什么的.

------解决方案--------------------
默认为当前目录,即程序所在的目录。
------解决方案--------------------
后来我用codeblocks,这样写就建在了C盘根目录下
----------------------
编译后的exe文件单独运行呢?
我觉得肯定是当前文件夹吧。。。
------解决方案--------------------
一般建立在可执行文件所在目录
------解决方案--------------------
程序所在的当前目录
------解决方案--------------------
创建在当前的目录,就是调用你那个程序的那个目录。不然你在C:\执行那个程序就在C:\创建
你在那个程序目录执行,就在那个可执行程序目录。
------解决方案--------------------
程序都有当前路径的概念
------解决方案--------------------
和执行程序在同一个目录。
------解决方案--------------------
当前工作目录(currrent working directoy),不是程序所在的目录.

edit.exe myfile.txt 

myfile.txt会在你执行以上命令的目录下,而不是edit.exe所在的目录.
------解决方案--------------------
_getcwd, _wgetcwd
Get the current working directory.

char *_getcwd( char *buffer, int maxlen );

wchar_t *_wgetcwd( wchar_t *buffer, int maxlen );

Routine Required Header Compatibility 
_getcwd <direct.h> Win 95, Win NT 
_wgetcwd <direct.h> or <wchar.h> Win NT 


For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version 
LIBCMT.LIB Multithread static library, retail version 
MSVCRT.LIB Import library for MSVCRT.DLL, retail version 


Return Value

Each of these functions returns a pointer to buffer. A NULL return value indicates an error, and errno is set either to ENOMEM, indicating that there is insufficient memory to allocate maxlen bytes (when a NULL argument is given as buffer), or to ERANGE, indicating that the path is longer than maxlen characters.

Parameters

buffer

Storage location for path

maxlen

Maximum length of path in characters: char for _getcwd and wchar_t for _wgetcwd

Remarks