0

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!

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Randomppl
0

For file operations, look up the fstream header. The basic code looks something like this:

#include <fstream>

using namespace std;

int main()
{
  fstream file;

  file.open( "whatever.whatever" );
  // Check to make sure the file is open with file.is_open()
  // Read data line by line using file.getline(); works just like cin.getline()
  // You can use file.eof() to check if you're at the end of the file (eof stands for end of file)
  file.close();

  return 0;
}

For your second question, you should probably read http://www.cplusplus.com/doc/tutorial/arrays.html

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.