Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is the code snippet

C#
v1=fopen("Input.txt","r");
    getline(v1,c);
    while ( v1 )
    {
        ch += c;
        getline(v1,c);
    }


I get an error
"no instance of overloaded function "getline" matches the argument list
argument types are: (FILE *, std::string)"
while the v1 is file pointer and c is the string.....
Posted
Comments
Praveen Kumar Upadhyay 18-Dec-14 7:59am    
Can you please mention the declarations also??
Member 10099183 18-Dec-14 10:11am    
FILE *v1;

string ch,c;
void main(void)
{
v1=fopen("Input.txt","r");
getline(v1,c);
while ( v1 )
{
ch += c;
getline(v1,c);
}


fclose(v1);
puts("Code:");
cout<<ch;
printf("\n\n");
Lexical(ch);
//updateToken();
getch();
}

If I were you I'd look very carefully at what fopen (the function that opens a file in the C runtime library) and getline (the function that reads a line of text from a stream in the C++ runtime library) actually do.

Basically you have to pick an IO model (either C's FILE pointer/function based API or C++'s stream/operator/function based API) and don't mix the two.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900