无法使用getline函数 [英] unable to use the getline function

查看:133
本文介绍了无法使用getline函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试在Wonsole应用程序(支持MFC)中逐行读取文件.
我创建了一个函数:

Hi all,

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

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



当我编译时说: error C2065: ''getline'' : undeclared identifier

我已经包含了这些标题:



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

I already included those headers :

#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 !!!

推荐答案

问题出在您的头文件上.
使用string代替string.h,即:
The problem is with your header files.
use string instead of string.h , i.e:
#include<string>


使用
#include <string>


代替


instead of

#include <string.h>


这篇关于无法使用getline函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆