getline未定义.....读取多行 [英] getline undefined..... reading multiple lines

查看:85
本文介绍了getline未定义.....读取多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经花了数小时试图使它生效,并且已经遍及您的网站,但对我来说却无济于事.....

i have spent hours trying to get this to work and have been all over your website and nothing is working for me.....

基本上,我正在为任务分配工作在银行系统上,这是我完成我的单元所需要做的最后一件事.

basically i am working on a banking system for an assignment and this is the final thing that i need to do in order to complete my unit.

我正在尝试从文本文件中读取多行,以便我可以输出它们.这些将是我以前的交易.

i am trying to read multiple lines from within a text file so i can output them. these will be my previous transactions.

我设法获取它来存储我的值,但是由于"getline"代码不起作用,我一生都无法读取这些行.这是我的代码

i have managed to get it to store my values but i cannot, for the life of me, read the lines due to the fact that the "getline" code doesnt work. here is my code

static int linecount = 0 ;
ifstream readTransactions;
readTransactions.open("deposit");
string line ;
if ( readTransactions ) 
{
    while (getline (readTransactions , line ) ) {
    cout<<linecount<<": "<<line<<'\n';//supposing '\n' to be line end
    linecount++ ;
}
readTransactions.close( ) ;
return 0 ;

推荐答案

您可能忘了包含string标头:

#include <string>

这篇关于getline未定义.....读取多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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