• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
fopen
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fopen


  • Subject: fopen
  • From: rckrueger <email@hidden>
  • Date: Mon, 02 Jul 2012 12:11:23 -0500

I am just learning c, and this is a beginner's question.  I am using Xcode 4 (Command Line tool) to create a program that will read a simple text file (a number 1234).  When I use the code:


#include <stdio.h>

int main(int argc, const char * argv[])
{ FILE *inputfile; // a pointer to the input file
inputfile = fopen("test.txt", "r");

to find and open the test.txt file which I have in the Project folder, same level as the main.c file, I get the error message: 

Thread 1:  EXC_BAD_ACCESS (code=1, address=0x68 

which I guess means that it can't find the file.


When I use this line to look for the file on the desktop:

inputfile = fopen("/users/robertkruegertiger/desktop/test.txt", "r");
the program works as expected.

How do I get the program to find the test.txt file in the Project folder.  I have already used the "Add Files to FileReadExample..", which copied it from the Desktop folder to the same folder as the main.c code.  What more needs to be done?  TIA

postscript:  And when the program finds the file and works properly, will it automatically write subsequent files in the same folder?
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: fopen
      • From: Mark Wagner <email@hidden>
    • Re: fopen
      • From: rckrueger <email@hidden>
    • Re: fopen
      • From: "Justin C. Walker" <email@hidden>
    • Re: fopen
      • From: Ken Thomases <email@hidden>
    • Re: fopen
      • From: Conrad Shultz <email@hidden>
    • Re: fopen
      • From: Thomas Wetmore <email@hidden>
    • Re: fopen
      • From: Fritz Anderson <email@hidden>
    • Re: fopen
      • From: Scott Ribe <email@hidden>
  • Prev by Date: Re: Console Window
  • Next by Date: Re: Console Window
  • Previous by thread: Re: Console Window +...
  • Next by thread: Re: fopen
  • Index(es):
    • Date
    • Thread