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 3422716
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:16:42+00:00 2026-05-18T06:16:42+00:00

I am writing something in C using Netbeans 6.9.1 (its a requirement) and I

  • 0

I am writing something in C using Netbeans 6.9.1 (its a requirement) and I stumbled upon a peculiar bug. When I try to run this code from Netbeans:

#include <stdio.h>
#include <stdlib.h>
#include "company_description.h"


company_description read_company_description() {
    char file_name[FILE_NAME_BUFFER_SIZE];
    FILE *company_description_file;
    company_description cd;


    printf("Please enter the name of the file containing the "
            "company's description: \n");
    scanf("%50s", file_name);


    company_description_file = fopen(file_name, "r");
    if(company_description_file != NULL) {
        printf("file is not null\n");
    }
    fscanf(company_description_file, "%s%s%s%s%s%s", cd.company_name,
        cd.name_file_deliveries_info, cd.name_file_industrial_park,
        cd.name_file_places, cd.name_file_roads, cd.name_file_vans_info);
    return cd;
}

I get this output:

Please enter the name of the file containing the company's description: 
name_file.txt
Segmentation fault
Press [Enter] to close the terminal ...

Ok I say to myself, from my point of vie there is nothing wrong with this code and I go to
~/path/to/NetbeansProject/dist/Debug/GNU-Linux-x86 and try to run the executable from there and it works. I forgot to mention that the file that should be read is in that same folder, exactly where the executable is. Now there might be a mistake on my side but I don’t see it so any thoughts about this would be helpful. Thanks!

  • 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-05-18T06:16:42+00:00Added an answer on May 18, 2026 at 6:16 am

    As to why it doesn’t run in Netbeans: working directory is probably incorrect – when you run from Netbeans, the working directory is not necessarily the same as where the executable resides.

    I do not have Netbeans installed, but you can set the working directory (what directory the system thinks the executable was executed in) in your project’s settings.

    I also agree with aschelper’s answer – if you don’t get a valid FILE * back you don’t want to continue running that file code.

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

Sidebar

Related Questions

Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws a
When writing async method implementations using the BeginInvoke/EndInvoke pattern the code might look something
I was writing something using generics and to my surprise I found that this
I'm writing an application using WPF, and I need to make something that looks
So I am writing something using augment for inheritance and for some reason I
I'm writing something that I would like to print in Latex and I'm using
I'm currently writing something of a quiz program. This program throws questions at the
I came across this: Writing a compiler using Turbo Pascal I am curious if
How can I do this with generics? In my current code, I am writing
I am writing something that will allow users to search through a log of

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.