Help plz

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2008
Posts: 2
Reputation: Randomppl is an unknown quantity at this point 
Solved Threads: 0
Randomppl Randomppl is offline Offline
Newbie Poster

Help plz

 
0
  #1
Oct 9th, 2008
i wanna noe how to write a code that will read lines from a file and then put those lines into an array. and will this make a double of arrayB if arrayA is empty and arrayB is filled? arrayA[10]=arrayB[10]

help of any kind will be greatly appreciated!
Last edited by Randomppl; Oct 9th, 2008 at 11:09 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 39
Reputation: Evan M is an unknown quantity at this point 
Solved Threads: 5
Evan M's Avatar
Evan M Evan M is offline Offline
Light Poster

Re: Help plz

 
0
  #2
Oct 9th, 2008
For file operations, look up the fstream header. The basic code looks something like this:

  1. #include <fstream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. fstream file;
  8.  
  9. file.open( "whatever.whatever" );
  10. // Check to make sure the file is open with file.is_open()
  11. // Read data line by line using file.getline(); works just like cin.getline()
  12. // You can use file.eof() to check if you're at the end of the file (eof stands for end of file)
  13. file.close();
  14.  
  15. return 0;
  16. }

For your second question, you should probably read http://www.cplusplus.com/doc/tutorial/arrays.html
Last edited by Evan M; Oct 9th, 2008 at 11:39 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2
Reputation: Randomppl is an unknown quantity at this point 
Solved Threads: 0
Randomppl Randomppl is offline Offline
Newbie Poster

Re: Help plz

 
0
  #3
Oct 10th, 2008
I actually solved the problem.. thx anyway for your help.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC