🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.c
Article #309647

Czytanie z pliku wiersza do stringa zamiast bufora

#309647
From: Borneq
Date: Sun, 04 Feb 2018 20:37
21 lines
1306 bytes
W Google gdy szukam czytanie pliku tekstowego linia po linii, otrzymuję 
coś takiego:
#include <iostream>
#include <fstream>

using namespace std;


.....
	ifstream infile(filename);
	string line;
	char buf[4096];
	while (!infile.eof())
	{
		infile.getline(buf, 4096);
		line = buf;		
	}

Mam bufor, spory, ale może być niewystarczający, gdy plik to głównie 
jedna długa linia (np. html, xml)
Czy jest możliwość czytania do stringa zamiast bufora?
Technical Details
Message-ID: <p57qu7$vtj$1@node1.news.atman.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
From: Borneq <borneq@antyspam.hidden.pl>
Newsgroups: pl.comp.lang.c
Subject: Czytanie z pliku wiersza do stringa zamiast bufora
Date: Sun, 4 Feb 2018 21:37:26 +0100
Organization: ATMAN - ATM S.A.
Lines: 21
Message-ID: <p57qu7$vtj$1@node1.news.atman.pl>
NNTP-Posting-Host: public-gprs351732.centertel.pl
Mime-Version: 1.0
X-Trace: node1.news.atman.pl 1517776647 32691 37.47.5.53 (4 Feb 2018 20:37:27 GMT)
X-Complaints-To: usenet@atman.pl
NNTP-Posting-Date: Sun, 4 Feb 2018 20:37:27 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0
X-Mozilla-News-Host: news://news.atman.pl:119
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit