0

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;
}
2
Contributors
1
Reply
10
Views
3 Years
Discussion Span
Last Post by Ancient Dragon
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());

Edited by Ancient Dragon

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.