Try something like this to read the file (don't use
char
s like you're doing and you won't have to worry about buffer overflows and such).
#include <string>
#include <iostream>
#include <fstream>
void main()
{
using namespace std;
ifstream ifs("1.txt");
if (!ifs)
{
cerr << "Error opening file!" << endl;
return;
}
string line;
while (getline(ifs, line))
{
cout << line << endl;
}
}