Solved

fstream !!! how to read

Posted on 2000-05-11
5
299 Views
Last Modified: 2010-04-02
I wrote simple program which use fstream to write 480000 integers in file
That part work fine. But I dont know how to read data from that file in int array;
I tryed to use ifstream but I'm not getting my values back;
I'm new to c++ and this subject so if possible give me the code which can open file and read all values inside it


Regards
Vedran
0
Comment
Question by:xtvca
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:Wyn
ID: 2801557
null
0
 
LVL 5

Accepted Solution

by:
Wyn earned 20 total points
ID: 2801561
Hi xtvca:

You can write it this way:

int main(int argc, char* argv[])
{
      ofstream of("my.dat");
      for(int i=0;i<=48000;i++)
            of<<???<<endl;
      return 0;
}

And read back:
int main(int argc, char* argv[])
{        int dada[48000];
      ifstream if("my.dat");
      for(int i=0;i<48000;i++)
            if>>dada[i];
      return 0;
}

Regards
Eirnava...
0
 

Author Comment

by:xtvca
ID: 2804896
I'll try
Thanks
0
 

Author Comment

by:xtvca
ID: 2836333
sorry for delay

this shold work but it has some problem (in my case)

No mather i found some other way to deal with it

regards
0
 

Author Comment

by:xtvca
ID: 2847545
Comment accepted as answer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ assignment question 7 169
C Language combined operators 28 106
C++ :Change value from  DisableCMD registry 4 51
What is sub-make ? 2 39
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now