I'm trying to read the data from a file using pointers but it gives error at the getline part that goes by "no instance of overloaded function". Couldn't figure out how to go about this..
Code is below:
#include<iostream>
#include<fstream>
using namespace std;
void read(const char * const, char const *);
int main()
{
char filename[20] = { "sentence.txt" }, data[50] = { '\0' };
read(filename, data);
return 0;
}
void read(const char * const ptr, char const * ptr2)
{
ifstream file;
file.open(ptr);
if (!file.is_open())
{
cout << "File not found " << endl;
exit(0);
}
else
{
while (!file.eof())
{
file.getline(ptr2, 49, ' ');
cout << ptr2 << endl;
}
file.close();
}
}