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!

Recommended Answers

All 2 Replies

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

I actually solved the problem.. thx anyway for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.