no matching function for call to `getline(std::string&, char&)'
Why is this error occuring?
HELP ME SOLVE THIS
My Aim is to copy each character or integer to an array
A.S.A.P
MY PROGRAM:-

#include <fstream>
#include <iostream>
#include<conio.h>
#include<string.h>
using namespace std;

int main () 
{ char a[50];

ifstream someStream( "txt.txt" );


string line;


getline( someStream, line );


while( !someStream.eof() ) 
{

getline( someStream, line );
cout<<line<<endl;
for(int i=0;i<=50;i++)
{
getline(line,a[i]);
}
}


getch();
return 0;
}

There is a different form of getline() that is used with std::string.

line.getline(someStream);

After the above all the characters are in the std::string line. Why would you want to copy them to a character array? You don't need a loop to do that, just this one line. But there is rarely any reason to do it.

strcpy(a,line.c_str());

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.