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

  • Home
  • SEARCH
  • 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 7413221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:39:45+00:00 2026-05-29T06:39:45+00:00

I am attempting to compile and run a test C program in Xcode. This

  • 0

I am attempting to compile and run a test C program in Xcode. This program reads 5 symbols from a text file and closes it. The program builds successfully, but when I try to run the program I get the error: GDB: Program received signal: “EXC_BAD_ACCESS” around fclose(in).

#include <iostream>
#include <unistd.h>

int main (int argc, const char * argv[])
{
    bool b;
    char inpath[PATH_MAX];
    printf("Enter input file path :\r\n");
    std::cin >> inpath;
    FILE *in = fopen(inpath, "r+w");
    char buf[5];
    fread(&buf,sizeof(buf),5,in);
    printf(buf);
    fclose(in);
    return 0;
}

What could be a cause of this?

  • 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-29T06:39:46+00:00Added an answer on May 29, 2026 at 6:39 am

    Ah! sizeof(buf) will return 5, so you’re asking for 25 bytes in a 5-byte buffer. This overwrites auto storage and clobbers in.

    And, of course, note that fprint(buf) will be attempting to print a buffer with no terminating null, so it will print garbage beyond the end of what was read.

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

Sidebar

Related Questions

I am attempting to compile and run a C program in Xcode. This program
I am attempting to compile/run a sample WCF application from Juval Lowy's website (author
I am attempting to compile/run a sample WCF application from Juval Lowy's website (
I have been attempting to compile/run a sample WCF application from Juval Lowy's website
I'm attempting to compile a file that instantiates this class. GCC gives me cryptic
All this originated from me poking at a compiler warning message (C4267) when attempting
Attempting to use the data series from this example no longer passes the JSONLint
I'm attempting to compile a Flex application from an ANT script, inside of Eclipse
I'm getting this error when I run my app (not at compile time): Could
When attempting to compile my C# project, I get the following error: 'C:\Documents and

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.