• 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
Re: Problems with fstream
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with fstream


  • Subject: Re: Problems with fstream
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 9 Jun 2008 19:41:36 -0700


On 9 Jun '08, at 6:26 PM, Paulo Ferreira wrote:

I tried to chage the pontos.txt to pontos.cpp, but it didn't work =P ... yes, the pontos.txt and pontos.cpp are in the project.
SO, does someone has any idea how to solve this problem?


Your code is making the assumption that at runtime the current directory is set to the directory that pontos.txt is in. There's no reason this needs to be the case. You should be using absolute paths when opening files.

If your target builds some type of bundle, then you should use CFBundle or NSBundle APIs to locate the resource file.

If not (i.e. it's a command-line tool) then you have to take into account that the CWD could be set to any arbitrary path when the binary is launched. The general way to find the location of the binary is to look at the directory of argv[0]. The resource file will, I believe, be copied to the same directory as the executable.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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: Problems with fstream
      • From: "Clark Cox" <email@hidden>
References: 
 >Problems with fstream (From: Paulo Ferreira <email@hidden>)

  • Prev by Date: Problems with fstream
  • Next by Date: Re: Problems with fstream
  • Previous by thread: Problems with fstream
  • Next by thread: Re: Problems with fstream
  • Index(es):
    • Date
    • Thread