Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,185 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,061 people online right now. Registration is fast and FREE... Join Now!




Using Xcode

 
Reply to this topicStart new topic

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

barnwillyb
3 Aug, 2007 - 10:00 PM
Post #1

D.I.C Head
**

Joined: 22 May, 2007
Posts: 55


My Contributions
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 barnwillyb: 3 Aug, 2007 - 10:01 PM
User is online!Profile CardPM
+Quote Post

Xing
RE: Using Xcode
4 Aug, 2007 - 04:25 AM
Post #2

D.I.C Addict
Group Icon

Joined: 22 Jul, 2006
Posts: 723



Thanked: 2 times
Dream Kudos: 1575
My Contributions
It should work. What is the error you are getting? Have you chosen the right project option?
User is offlineProfile CardPM
+Quote Post

barnwillyb
RE: Using Xcode
4 Aug, 2007 - 10:47 AM
Post #3

D.I.C Head
**

Joined: 22 May, 2007
Posts: 55


My Contributions
QUOTE(Xing @ 4 Aug, 2007 - 05:25 AM) *

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
User is online!Profile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 01:12AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month