こんにちは、Microsoft Visual Studio Ultimate 2010で以下のコードによって生成された.exeファイルを実行しようとしていますが、ファイルが作成されていません。
LinuxでGCCを使用してコンパイルおよび実行すると、このコードは完全に正常に機能します。
繰り返しになりますが、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;
}