Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

omegasyphon

problem with reading in a file

This topic is 6546 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok i have a file defined as so 00 00 00 01 02 01 01 01 01 now i open the file the following way ifstream fin("data.dat"); ofstream fout("data1.txt");
        
while (!fin.eof())
{
     fin<<a;
     fout>>a;
}
fin.close();
fout.close();
        
now when i go to open my output file data.txt all i get is 1 zero in the top left corner and i dont know why? also im using msvc5++ on win98 Edited by - omegasyphon on 7/20/00 2:48:58 PM

Share this post


Link to post
Share on other sites
Advertisement
What are you trying to do? Do you want to fill data1.txt with what's in data.dat? If so, then you shouldn't be using cin or cout. You should be doing:

    
fin << a;
fout >> a;


-> Briar LoDeran <-

Edited by - BriarLoDeran on July 20, 2000 3:30:44 PM

Share this post


Link to post
Share on other sites
    
ifstream fin("data.dat");
ofstream fout("data1.txt");
int a;
fin >> dec;
while (!fin.eof())
{
fin >> a;
fout << a;
}
fin.close();
fout.close();




"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions

Share this post


Link to post
Share on other sites
well i forgot to say that im trying to read in the data.dat file and load it into an array of 3x3 but right now im just doing testing to get my algorithm working to read it into an array and display it in my data.txt file to see if it works

Share this post


Link to post
Share on other sites
[source]
ifstream fin("data.dat");
int array[3][3];
fin >> dec;
for (int i = 0; i < 3; i++)
{
for (int k = 0; k < 3; k++)
{
fin >> dec[k];
}
}
fin.close();


"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!