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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:25:35+00:00 2026-05-25T10:25:35+00:00

I am working on figuring out how to use Xcode 4 to debug c++

  • 0

I am working on figuring out how to use Xcode 4 to debug c++ projects.

I have basically copy pasted a working c++ executable that when compiled from the terminal ran fine.

However, i was thinking it might be nice to use Xcode for debugging. So I am trying to migrate the single .cpp file into Xcode as a command line tool.

I need to read in a file called numbers.txt (which I supply through a command line argument) which is located in my project directory, and then out put to a file (whose name I also specify as an argument.)

The problem I am running into is that the files that are supplied as command line arguments are failing to open.

    ifstream in;
    ofstream out;
    in.open(argv[1]);
    out.open(argv[2]);

I have checked to make sure that the arguments are being properly passed and are named correctly. The ifstream in is being supplied with `numbers.txt’, which I want to open a text file that I already have.

However when I check to make sure the ifstream is open:

    if(in.is_open() == false){
          cerr << "Unable to open input file" << endl;
          return 1;
    }

I get the error.

I suspect this has something to do with how Xcode organizes the project.

my numbers.txt file is just sitting in the Xcode project folder, and I have only one .cpp class and one product, the executable.

anyone know what I am missing here?

  • 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-25T10:25:36+00:00Added an answer on May 25, 2026 at 10:25 am

    The executable built by Xcode is in a different folder than the project. Passing in the name of the file without an absolute path before it will cause the executable to look for it in the wrong place, which is why it can’t be found. Some of the possible solutions are to include the file as part of the build process (so it ends up in the same directory as the executable) or to pass the file to be opened by its absolute path. There are other ways to solve the problem, too, but hopefully that should be enough to get you started.

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

Sidebar

Related Questions

I've been working on figuring out how to receive HTTP Headers via a request
I am stuck figuring out a working SQL Query for the fallowing: I need
I'm having trouble figuring out why my web service is not working correctly when
I'm working on a Wake on LAN service that will run from a web
I am working through the first steps of figuring out Nservicebus and planning a
I'm working on my homework and am having trouble figuring out the correct syntax
Ok so I'm working on my homework and am having trouble figuring out how
I've been working on a application for iPad that use sockets to communicate with
I'm working on a site that has a product info laid out in a
I'm having a bit of trouble figuring out something that should be simple. I

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.