473,395 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

help(about buffer)

i have a string s1 and if i want to make such a thing
strstreambuf bbuf(char*,int);
it only accepts a pointer and i have a string how can i do this i ll be
happy if u can help me

Oct 29 '05 #1
3 1082
berkay wrote:
i have a string s1 and if i want to make such a thing
strstreambuf bbuf(char*,int);
it only accepts a pointer and i have a string how can i do this i ll be
happy if u can help me


Why on earth do you want to make a strstreambuf? It's a really unusual
type of object to want to make, normally it is only made behind the
scenes by other classes.

Anyway the bad news it that you can't make a strstreambuf from a string,
only from a char pointer.

I expect that what you really want to make is a istringstream, like this

string str = ...;
istringstream buf(str);

Perhaps you should explain what you are trying to do instead of what you
think you want and I could help better.

john
Oct 29 '05 #2
"berkay" <be**********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
i have a string s1 and if i want to make such a thing
strstreambuf bbuf(char*,int);
it only accepts a pointer and i have a string how can i do this i ll be
happy if u can help me


If the bbuf doesn't change the string, you can pass sl.c_str() but this is a
const pointer. So you would have to const_cast it const_cast<char*>(
sl.c_str() ) BUT, make 10000% sure that bbuf does NOT change the data.

Now, if it does it is possible to pass sl.data() which is not const, it can
be changed, but it is a fixed length buffer, make sure your bbuf doesnt' try
to write past the end of it.

Oct 29 '05 #3
TIT
berkay sade:
i have a string s1 and if i want to make such a thing
strstreambuf bbuf(char*,int);
it only accepts a pointer and i have a string how can i do this i ll be
happy if u can help me


Why use the deprecated strstream and not the newer stringstreams
(<sstream>)?

basic_stringbuf<char> buf(s1);

or even more convenient:

std::istringstream istrm(s);
std::ostringstream ostrm(s);

but to answer your question:

std::strstreambuf bbuf(s1.c_str(),s1.size());

TIT
Oct 29 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phil | last post by:
Hi, I need help about _target the code links" in" page but I need to link "out" page wirh "_blank" the cose is: <link>http://www.mysite.com</link> Thanks
2
by: xeyder | last post by:
Hi everyone.. I need help about graph theory ( network problems) .. I have below problem . Does anyone know any existence algorithms or solutions to this problem ?? The Problems is: "...
2
by: xeyder | last post by:
Hi everyone.. I need help about graph theory ( network problems) .. I have below problem . Does anyone know any existence algorithms or solutions to this problem ?? The Problems is: " We...
3
by: derek | last post by:
I m looking for help about python-sane, The follow sample code try to grab the image from the webcam through a /dev/video0 on linux, it works fine for the first 185 times, but it freeze the...
2
by: maxwin | last post by:
Ps i need help about how to create a simulation of doodlebugs life Problem: anaylysis The goal for this problem is to create a simple two-dimensional predator-prey simulation. In the simulation...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
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...

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.