• 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
Using fstream
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using fstream


  • Subject: Using fstream
  • From: Adam <email@hidden>
  • Date: Wed, 7 Feb 2007 17:30:18 -0800

Hello all,

I created a short program using <fstream>, and in it I created a file that I wanted to put information in, and later extract the information. (see code below) The problem is that it doesn't work - I'll input the data a second later and it doesn't display any information that it stored. Is this a code bug, or something in the way I compiled it?

~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
code
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
#include <iostream>
#include <fstream>

using namespace std;

char arr_words[50];
int fifty_one;
ifstream fin("input.txt");
ofstream fout("input.txt");

int main()
{
fout << "Dude, am I coming in loud and clear?" << 51 << flush; //saves file inside project
fout.close(); //close teh file!

fin.getline(arr_words, 49); //using getline to get whole words
fin >> fifty_one;
cout << fifty_one << endl << arr_words;
fout << arr_words << fifty_one << flush;
return 0;
}

~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~





All help is appreciated and thanks in advance.

~ < [ / Adam-o \ ] > ~

+-------------------------------------------+
| My computer's Stats                      |
| Mac OS 10.4.8                               |
| 1 Ghz Apple Powerbook G4        |
| Xcode v. 2.4.1                                 |
+-------------------------------------------+

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please keep your posts straight and 
to the point. Also please comment 
the code you use as I am still learning 
OpenGL and Xcode and may not yet 
understand the meaning of the command.
 Thank you.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


 _______________________________________________
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: Using fstream
      • From: John Daniel <email@hidden>
  • Prev by Date: Re: CppUnit - missing include?
  • Next by Date: Re: Using fstream
  • Previous by thread: Re: Bizarre x86 segment layout problem causing select() slowdown: solved, sort of
  • Next by thread: Re: Using fstream
  • Index(es):
    • Date
    • Thread