Using Xcode

Xcode in C++ doesn't read my file! Any help is appreciated.

Page 1 of 1

2 Replies - 8166 Views - Last Post: 04 August 2007 - 11:47 AM Rate Topic: -----

#1 barnwillyb  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 108
  • Joined: 22-May 07

Using Xcode

Posted 03 August 2007 - 11:00 PM

File is a text file called Data.txt and just has this sentence in it: The air heaved suddenly with sounds of trumpets calling.



#include <iostream>
#include <fstream>

// introduces namespace std
using namespace std;

const char * file = "Data.txt";

int main (int argc, char * const argv[]) {
	char ch;

  ifstream fin;
  fin.open(file);

  if (fin.is_open()) {
    while (fin.get( ch ) )
      cout << ch;
  }
  fin.close();

	return 0;
}


This code worked in CodeWarrior but I cannot get it to work in Xcode.

Thanks for looking!
barnwillyb

This post has been edited by JackOfAllTrades: 23 December 2011 - 03:50 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Using Xcode

#2 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: Using Xcode

Posted 04 August 2007 - 05:25 AM

It should work. What is the error you are getting? Have you chosen the right project option?
Was This Post Helpful? 0
  • +
  • -

#3 barnwillyb  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 108
  • Joined: 22-May 07

Re: Using Xcode

Posted 04 August 2007 - 11:47 AM

View PostXing, on 4 Aug, 2007 - 05:25 AM, said:

It should work. What is the error you are getting? Have you chosen the right project option?


There is no error. It is in the C++ project in Xcode. All of my other programs work with no problems but this simple one.

It prints this:

[Session started at 2007-08-04 12:37:23 -0600.]

Read File has exited with status 0.

I have tried using the Debugger but it just goes through each step and exits.

barnwillyb
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1