Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7803409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:34:32+00:00 2026-06-02T01:34:32+00:00

Hello there I am trying to execute the .exe file generated by the below

  • 0

Hello there I am trying to execute the .exe file generated by the below code in Microsoft Visual Studio Ultimate 2010 and I don’t see the file being created.

This code when compiled and executed in Linux with GCC works absolutely fine.

To repeat I am able to use the file created in Linux !! but in Windows the .exe program fails to create the file for the name entered by user at command prompt.

Can someone please let me know as to where I am going wrong with respect to the compilers?

Sincere Thanks

// 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;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:34:34+00:00Added an answer on June 2, 2026 at 1:34 am

    In all probability you will press the ENTER after entering your file name. So \n also gets into cNotes_buffer. Now you try to create a file with this buffer as the file name. And I don’t think you can create file names with \n in it.

    Do something like if you’ve pressed the return key

    cNotes_buffer[strlen(cNotes_buffer)-1]=0;
    

    EDIT: Newlines can be present in filenames in linux but not so on Windows This explains why your file got created in Linux but not on Windows.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to include Core Location and I'm trying to follow this tutorial: http://www.mobileorchard.com/hello-there-a-corelocation-tutorial/
I'm trying to do a simple fork -> execute another program -> say hello
I'm trying to extend one of my WebApps using IronPython, unfortunately the code below
I was trying to execute the following commands. de=hello world if [ $de -eq
OS: ubuntu 11.10 Webserver: Apache Code: PHP Hello I am trying to exec a
I am trying to extract data from this String: Hello there. Blah blahblah blah
In my example code below, you can see that I have been trying to
Hello there Iam trying to use the http://paste.kde.org api in order to make it
Hello there I am a newbie trying to prove the working of RS 232
Hello there!. I am trying to use a public api from wunderground (more info

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.