Reading a line from a file
I'm trying to read in a file and store each line in the file into an array? I need some help, I think im doing something wrong
Code:
int main()
{
ifstream input;
ofstream output;
int count=0;
string word;
char inFileName[20];
char outFileName[20];
cout << "Enter the input file name >> ";
cin >> inFileName;
cout << "Enter the output file name >> ";
cin >> outFileName;
input.open(inFileName);
if(input.fail())
{
cout << "Unable to open " << input << " now exiting." << endl;
exit(1);
}
output.open(outFileName);
if(output.fail())
{
cout << "Unable to open " << output << " now exiting." << endl;
exit(1);
}
cout << "Enter the number of entry to be read >>";
cin >> count;
char temp[count];
for (int i =0; i <count; i++)
{
input >> temp[count];
count++;
}
for(int i =0; i <count; i++)
{
cout << temp[count]<< endl;
}
input.close();
output.close();
return 0;
}