473,773 Members | 2,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to copy iostream& data into string?

33 New Member
hello,
im having problem to copy the data from iostream& into string.and im not sure am i doing the right way by using getline.can anyone give hints how to solve this.

here's to make things clear:


Expand|Select|Wrap|Line Numbers
  1.  
  2. //method that reads through the stream and breaks it into words and sentence
  3.  
  4. Document*Repository::addDoc(iostream& inStream,string docId)
  5.  
  6. //test core
  7.  
  8. Repository r1;
  9. stringstream ss;
  10.  
  11. string s1 = "Hello World;"
  12.  
  13. ss.clear();
  14. ss<<s1;
  15. r1.addDoc(ss,"1")
  16.  
  17.  
  18.  
thanks in advance
Oct 20 '09 #1
5 2308
Banfa
9,065 Recognized Expert Moderator Expert
That code snippet does access iostream& and doesn't copy into a string.

It copies a string into a streamstream which looks ok to me.
Oct 20 '09 #2
hanna88
33 New Member
thanks for your reply.

@Banfa
so how can i access the copied string into streamstream should i convert it back to string in order to use string method like strtok?
Oct 20 '09 #3
Banfa
9,065 Recognized Expert Moderator Expert
If you mean should you convert it into a C string to use strtok then no. strtok is an evil function and should be avoided.

However you could convert it back into a string (the C++ variety) and use the member functions of string (find and substr) to tokenise it.
Oct 20 '09 #4
hanna88
33 New Member
the string is been passed in iostream& form and the only for me to get access on the string is getline().im not sure whether it is right by using getline() first then convert it into string in order to tokenize it.

any hint would be great! thanks again
Oct 20 '09 #5
Banfa
9,065 Recognized Expert Moderator Expert
You don't need to use getline then convert it to a string, getline can read straight into a string

string getline reference

Even so conversion to a string is still better than calling strtok.
Oct 20 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2023
by: Ken | last post by:
How do I copy data from one file to another? from $_SESSION to "fname" datafile.php has fname: $_SESSION; lname: $_SESSION; I would like to automatically copy the data to
1
8627
by: sbh | last post by:
I need to copy data from a table on one Oracle server to another. Scenario: Need to create a stored procedure in server a, database aa that will copy data from server b, database bb, table bbb to server a, database aa, table aaa. Let's say I have a user on server b, database bb named userB (password pw) that has rights to table bbb. Can anyone help me with the syntax - just for the connection part? Is this possible with a stored...
3
1421
by: thaar al_taiey | last post by:
hi their, How can i copy data in MS-SQL 2000 from one table to another with different charactristic? thanks *** Sent via Developersdex http://www.developersdex.com ***
0
2783
by: Banx | last post by:
Hi everyone, i'm trying to copy data from a table in Pervasive database to a table in MySQL Does anyone know how to do it? :confused: Is it posible to copy data from another database prog to MySQL? :confused: Thanks for the help....
2
2236
by: Ken | last post by:
How can I copy data from SQL to MS Access using dsn-less connection and not using SQL DTS? I have this but am stuck. I just want to do an export but can't figure out how to do a "select into". It pastes the data in SQL instead of access. The below code will cycle but I will have to create a table to place the data first. Is there an easier way. Sub getTables() Dim cnnSQL As ADODB.Connection Dim cnnMSA As ADODB.Connection
0
1763
by: eyal | last post by:
Hello, I want to open 2 workbook, , lets say workbook1 and workbook2 now I want to copy data from a sheet name "TEST" in workbook2 and paste the data to a sheet named "TEST" in workbook. now , I dont know the size of the data ,so I can't use the get_range option of the c# . I need a command like select.currentregion of the vba. antoher problem that I have is that I can't open 2 workbook with the
2
1556
by: isa | last post by:
Hello everyone, i want to transfer/copy data from MSDE to SQL Server 2000 and from SQL Server to MSDE, through Stored Procedures , not using a "Replication", kindly tell me how i make a SP for this as both datatbases are connetec through LAN, i mean MSDE on diff machine and SQL Server on other machine i make a new registration and connect with MSDE now how can i write a SP that copy data from table of 1 Database to other table of that...
2
1750
by: deviparimala | last post by:
Hi All, I'm opening 2 notepads in my windows application. I copy data from one notepad and paste it another notepad. The data should not get pasted into the second notepad. Can I handle this programatically? Any help will do......
1
1850
by: okonita | last post by:
Hi all, I have a need to copy data from one database/schema to a different database schema. Yes, I can use export/import but that is not "elegant". Yes, I can try a redirected Restore from Backup but this method has the irritating requirement of pause, set tablespaces and continue, again much manual intervention. What I am most interested in is this: The two databases are in the same instance/server. I want to be able to copy directly from...
0
1294
by: Bxitty | last post by:
I have a package that works great when I run it from the SQL2000 environment. This job transfers data from SQl2005 table to a mainframe DB2 table. After I migrated the job to SQL2005 and ran it (with'n th SQL2000 desiigner editor) it fails with the message Step Error Source: Microsoft Data Transformation Services (DTS) Data Pump Step Error Description:The number of failing rows exceeds the maximum specified. Step Error code:...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
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...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
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...
0
6717
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();...
0
5355
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...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.