I'm trying to make a subprogram,
Code:
void file2String(ist ream& in, string& theFile)
that can read an entire file into a string variable, including line
breaks and i have no idea what im doing. I'm using the GNU g++
compiler on Fedora 4 Linux Distribution.
Thanks in advance for the help 4 4303
owolablo wrote:
I'm trying to make a subprogram,
Code:
void file2String(ist ream& in, string& theFile)
that can read an entire file into a string variable, including line
breaks and i have no idea what im doing.
Use 'read' member of 'istream' and keep appending what you read to
the string, until an error or end-of-file.
I'm using the GNU g++
compiler on Fedora 4 Linux Distribution.
We don't care.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
On Wed, 11 Oct 2006 08:59:48 -0400, "Victor Bazarov"
<v.********@com Acast.netwrote:
>Use 'read' member of 'istream' and keep appending what you read to the string, until an error or end-of-file.
You can also reserve enough space to read the entire file with one
dynamcic allocation (but keep std::string as out param and check the
return values): http://www.cplusplus.com/ref/iostrea...eam/tellg.html
Best wishes,
Roland Pibinger
owolablo wrote:
I'm trying to make a subprogram,
Code:
void file2String(ist ream& in, string& theFile)
that can read an entire file into a string variable, including line
breaks and i have no idea what im doing.
Try this:
#include <iterator>
void file2string ( std::istream & in, std::string & str ) {
std::string dummy ( std::istreambuf _iterator<char> ( in ),
(std::istreambu f_iterator<char >()) );
str.swap( dummy );
}
Best
Kai-Uwe Bux
"owolablo" <ow********@yah oo.comwrites:
void file2String(ist ream& in, string& theFile)
that can read an entire file into a string variable, including line
breaks and i have no idea what im doing. I'm using the GNU g++
compiler on Fedora 4 Linux Distribution.
Thanks in advance for the help
in << ifstream(theFil e).rdbuf();
To read it into a string make `in' be a stringstream.
--
Gruß, Jens This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Venkat |
last post by:
Hi All,
I need to copy strings from a single dimensional array to a double
dimensional array.
Here is my program.
#include <stdio.h>
#include <stdlib.h>
|
by: Simon Schaap |
last post by:
Hello,
I have encountered a strange problem and I hope you can help me to
understand it. What I want to do is to pass an array of chars to a
function that will split it up (on every location where a * occurs in
the string). This split function should allocate a 2D array of chars
and put the split results in different rows. The listing below shows
how I started to work on this. To keep the program simple and help
focus the program the...
|
by: Jeroen Pot |
last post by:
Hi,
I have a dataset "Mydataset" which contains of a few fields. (lets say
dept_id and dept_name)
A user can select several of these, and i want to export this to an access
database.
I have a database with one table (dept) and identical colums as the dataset.
But i can't figure out how to get the dataset into the database.
|
by: DraguVaso |
last post by:
Hi,
I'm looking for a way to Copy and Paste Files to the clipboard.
I found a lot of articles to copy pieces of text and bitmaps etc, but nog
whole files.
Whay I need is like you have in windows explorer: when you do a right-click
on a file and choose Copy, and than paste it somewhere in my application and
vice versa.
|
by: Xavier Valdés |
last post by:
Hi all,
I would like to copy FILES from the clipboard to a desired folder from
VB.NET.
I was able to copy files (with filedrop data format) to the clipboard but I
don't know
how to catch this data (the entire data) and leave it (copy it) to a folder.
It doen't matter if the data I want to copy is a folder, a file or a group
of them. The
fact is I would like to copy the WHOLE data with a function.
| |
by: lgbjr |
last post by:
Hello All,
I¡¯m using a context menu associated with some pictureboxes to provide
copy/paste functionality. Copying the image to the clipboard was easy. But
pasting an image from the clipboard is proving to be more difficult. These
pictureboxes are bound to an AccessDB. If the user wants to add an image,
they select an image using an OpenFileDialog:
Dim result As DialogResult = Pic_Sel.ShowDialog()
If (result = DialogResult.OK) Then
|
by: Talal Itani |
last post by:
Hello,
I need the program I am writing to duplicate a folder, from one drive to
another drive. I need a progress report, and write-verify. What is a good
way to do that? I am using C# express, with XP.
T.I.
|
by: GS |
last post by:
from the online help, looks like to code step by step to copy content of
directory to another whereas I can use online line code for directory move
or delete.
I am using 2005 express .net 2
I did not any thing(or I did not have the right search term ) for copy
contents of directory to another and replacing /delete all files in the
target directory
Is there an easier way?
|
by: jodleren |
last post by:
While reading php.net I found
" bool copy ( string $source , string $dest )
Makes a copy of the file source to dest .
If you wish to move a file, use the rename() function. "
..... what? rename can move a file...?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |