我在VS2022上想把一个文本文件的内容做修改并写入另一个文本文件,并且删除原理的文本文件,将后面的文本命名为原来前面文本文件的名字。但是执行不了,a,b均输出-1.但是相同的方法在codeblocks上可以执行。 确实执行时相关文件都没有打开,也重启过VS尝试过了
请问这是什么问题呢
remove, _wremove
Delete a file.
int remove( const char *path );
int _wremove( const wchar_t *path );
Routine Required Header Compatibility
remove <stdio.h> or <io.h> ANSI, Win 95, Win NT
_wremove <stdio.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 0 if the file is successfully deleted. Otherwise, it returns –1 and sets errno either to EACCES to indicate that the path specifies a read-only file, or to ENOENT to indicate that the filename or path was not found or that the path specifies a directory. This function fails and returns -1 if the file is open.
rename, _wrename
Rename a file or directory.
int rename( const char *oldname, const char *newname );
int _wrename( const wchar_t *oldname, const wchar_t *newname );
Routine Required Header Compatibility
rename <io.h> or <stdio.h> ANSI, Win 95, Win NT
_wrename <stdio.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 0 if it is successful. On an error, the function returns a nonzero value and sets errno to one of the following values:
EACCES
File or directory specified by newname already exists or could not be created (invalid path); or oldname is a directory and newname specifies a different path.
ENOENT
File or path specified by oldname not found.
EINVAL
Name contains invalid characters.
For other possible return values, see _doserrno, _errno, syserrlist, and _sys_nerr.