Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I m trying to read a file line by line in a wonsole application (supporting MFC).
I created a function :

C#
int  LineToStruct(CString TransLog)
{
    string ReadLine;
    ifstream infile(TransLog);
    while(!infile.eof())
    {
        getline(infile, ReadLine);
    }
    infile.close();
    return 0;
}


when I compile it says : error C2065: 'getline' : undeclared identifier

I already included those headers :
XML
#include "stdafx.h"

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


I looked in the internet but i had no clue to resolve that !!!
Posted
Updated 14-Aug-12 0:32am
v2

The problem is with your header files.
use string instead of string.h , i.e:
C++
#include<string>
 
Share this answer
 
v2
Comments
Schehaider_Aymen 14-Aug-12 6:36am    
Excellent Dude, i don't know what's the difference between the two headers (i ll check on them later) but thank you for your help, it works great.
Use
C++
#include <string>

instead of
C++
#include <string.h>
 
Share this answer
 
v2

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