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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:07:34+00:00 2026-05-15T00:07:34+00:00

i tried to read text file in xcode but this EXC_BAD_ACCESS message showed up

  • 0

i tried to read text file in xcode but this
“EXC_BAD_ACCESS message showed up when i tried to build my program

here is my code
and i put inputA.txt file in the same folder with project file
my friend told me that i should put txt file in debug folder is this why i cannot read txt
file in this code? please help me…

macbook user.

int main (int argc, const char * argv[]) {
    FILE* fp;  
    char mychar;  
    char arr[50][2] = {0, };  
    int i = 0;  
    int j, k;  
    graphType* G_;  
    G_ = (graphType*)malloc(sizeof(graphType));  
    Create(G_); 
    fp = fopen("inputA.txt", "r");
    //fp = fopen("inputB.txt", "r");
    //fp = fopen("inputC.txt", "r");

    while(1){
        for(j = 0 ; j < 2 ; j++){
            mychar = fgetc(fp);
            if(mychar == EOF)
                break;
            else if(mychar == ' ')
                continue;
            arr[i][j] = mychar;
        }
        i++;
    }
  • 1 1 Answer
  • 1 View
  • 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-15T00:07:34+00:00Added an answer on May 15, 2026 at 12:07 am

    Per default your binary will be generated in ProjectDir/build/Mode, with Mode being Debug or Release, and will have that as its working directory. If you want to refer to a file in the project directory, you’d have to use ../../input.txt in that case.

    The build locations are configured in the “Build Locations” section in a targets or projects build tab. The working directory can be manually changed in the settings for the executable (“General”, “Set the working directory to:”) if needed.

    If you are having doubts then you can always find out what the working directory is:

    #include <unistd.h>
    int main() {
        char buf[2048];
        getcwd(buf, sizeof(buf));
        printf("%s", buf);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read Japanese, and want to try processing some Japanese text. I tried this
I tried to read a file in a view like this: def foo(request): f
I read a text file from the hard drive, then I want to put
I need to read a text file when I start my program. I'm using
I have the following basic code to read a text file from a StreamReader:
I am trying to to read each line from a text file and put
I tried to read a text file which have only one line. File size
I've got a problem where I'm trying to read a text file like this:
I am trying to read some words from an online text file. I tried
I previously had code that used File.ReadAllLines() to read a text file and store

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.