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

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




Really annoying problem

 
Reply to this topicStart new topic

Really annoying problem

rubendodge
11 Apr, 2008 - 12:32 AM
Post #1

New D.I.C Head
*

Joined: 10 Jan, 2008
Posts: 9

Well I spent the past 4 hours trying to find why this code I have is failing to display the txt out of a txt file I have. I don't see why but the whole console goes blank after trying to run this option. Any help would be nice.

CODE
            {
                char c;
                char str[256];
                std::ifstream in("Your information.txt");
                in.open("Your information.txt");
                while(!in.eof())
                {
                in.getline(str, 256);
                cout << str;
                }
                in.close();
                break;
            }


This post has been edited by rubendodge: 11 Apr, 2008 - 12:33 AM
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Really Annoying Problem
11 Apr, 2008 - 12:33 AM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,465



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
Try removing the space from the file name.
User is offlineProfile CardPM
+Quote Post

rubendodge
RE: Really Annoying Problem
11 Apr, 2008 - 03:11 AM
Post #3

New D.I.C Head
*

Joined: 10 Jan, 2008
Posts: 9

Didnt help at all sad.gif any more tips?
User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Really Annoying Problem
11 Apr, 2008 - 03:17 AM
Post #4

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,539



Thanked: 98 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
The problem is here:
cpp

char c;
char str[256];
std::ifstream in("Your information.txt"); //file name is here
in.open(); //There's no need to put it in the brackets
while(!in.eof())
{
in.getline(str, 256);
cout << str;
}
in.close();


It's on the in.open() line.

Hope this helps smile.gif

This post has been edited by gabehabe: 11 Apr, 2008 - 03:18 AM
User is offlineProfile CardPM
+Quote Post

rubendodge
RE: Really Annoying Problem
11 Apr, 2008 - 11:03 AM
Post #5

New D.I.C Head
*

Joined: 10 Jan, 2008
Posts: 9

Removing in.open fixed the problem I was having Well anyways thanks dude I will be posting my source code here soon smile.gif.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/3/08 12:03AM

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