#### Archived

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

# problem with reading in a file

## Recommended Posts

omegasyphon    100
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; } 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 on other sites
BriarLoDeran    122
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 on other sites
ncsu121978    1344
  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 on other sites
omegasyphon    100
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 on other sites
ncsu121978    1344
[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