您好,我正在尝试在 Microsoft Visual Studio Ultimate 2010 中执行由以下代码生成的 .exe 文件,但没有看到正在创建的文件。
这段代码在使用 GCC 的 Linux 中编译和执行时工作得非常好。
重复一遍,我可以使用在 Linux 中创建的文件!但在 Windows 中,.exe 程序无法为用户在命令提示符下输入的名称创建文件。
有人可以让我知道我在编译器方面出了什么问题吗?
真诚的感谢
// filename.cpp : Defines the entry point for the console application.
#include "stdafx.h" //Please comment if code is to be executed in GCC
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
int main()
{
FILE *pFile;
char cNotes_buffer[100];
memset(cNotes_buffer,0,100);
printf("Please enter name of the LOG file - with tag MAX 100 characters!! \n");
if( fgets (cNotes_buffer , 100 , stdin) != NULL )
{
fclose (stdin);
}
printf("name of file %s \n", cNotes_buffer);
if ( ( pFile = fopen(cNotes_buffer,"a+") ) == NULL )
{
printf("ERROR OPENING FILE FOR LOGGING \n");
exit(0);
}
return 0;
}