txt data into array

Hi,
I need to read a text file, put its data into an array, process that data in the array, then write that out into a text file. I am having trouble reading tha text file data into an array. I need to use functions to do this. I will really appreciate any help. Here is what i have so far:

#include<iostream>
#include<fstream>
#include<stdlib.h>
#include<string.h>


using namespace std;

void ReadToMemory(char Memory[]);

int main ()
{
int MaxNumChar=10000;
char Memory[MaxNumChar];
ifstream InFile ("InputData.txt");
ofstream OutFile("OutputData.txt");

ReadToMemory(Memory);




InFile.close();
OutFile.close();
system("PAUSE");
return 0;
}

void ReadToMemory(char Memory[])
{
int MemIndex=0;
string line;
string filename;
cout << "\tPlease enter the file name: ";
cin >> filename;
ifstream in_file;
in_file.open(filename.c_str());
if(in_file.is_open())
{
cout << "\n\tFile successfully opened :-) \n\n";
while(in_file.good())
{
cout << "\tThe file is good :-) \n";
getline(in_file,line);
//checking
cout << line << endl;


for(int i=0;i<line.length();i++)
{
Memory[MemIndex]=line[i];
MemIndex++;
}
}

}

in_file.close();
}
Topic archived. No new replies allowed.