473,783 Members | 2,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Queries about strstream.h

hello to all,
#include<iostre am.h>
#include<conio. h>
#include <strstream.h>
void main()
{
clrscr();
strstream str;
char *a = new char[50];
int i;
cin >> i;
ostrstream s;
s<<"\nvalue of i is "<<i<<ends;
cout<<"\nIn s we have"<<s.str();

str<<i<<ends;
cout<<"\nusing rdbuf "<<str.rdbu f();

getch();
}

correct me if i am wrong.
Is Strstream is just used for converting interger and formatting it into strings.

what is the difference between "s.str()" and "str.rdbuf( )" ?
the output is the same.

Did strstream have anyother functions.
I checked c++ library , but i cannot understand a word.
thankyou in advance,
vishnu
Jul 22 '05 #1
6 2861
vishnu mahendra wrote:

Your textbook is due for recycling. Please don't sell it on.
#include<iostre am.h>
Wrong. The standard C++ header you want is called 'iostream',
without the ".h".
#include<conio. h>
Wrong. There is no standard C++ header corresponding to this one.
#include <strstream.h>
Wrong. This header and everything it provides is deprecated.
You should use the 'sstream' header and the 'stringstream'
class template instead.
void main()
Wrong. The main function always returns int.
{
clrscr();
Wrong. There is no way to clear the console's screen in standard C++.
strstream str;
Should be "std::stringstr eam str;", but why bother, if you're not going
to use it?
char *a = new char[50];
(i). You never delete [] the memory allocated here. That's bad.
(ii). You never use the variable a at all, so don't declare it.
(iii). Why 50?

Use std::string for strings.
int i;
cin >> i;
Should be "std::cin >> i;".

ostrstream s;
Should be "std::ostringst ream s;"
s<<"\nvalue of i is "<<i<<ends;
You don't need the "ends" with std::stringstre am,
since std::string doesn't need to be null-terminated.
cout<<"\nIn s we have"<<s.str();
OK, but qualify "cout" with "std::".
str<<i<<ends;
What was that for?
cout<<"\nusing rdbuf "<<str.rdbu f();
I daresay you don't need to know about std::basic_ios <>::rdbuf () yet.
getch();
Wrong. There is no way to wait for a single keypress in standard C++. }

correct me if i am wrong.
Is Strstream is just used for converting interger and formatting it into strings.
You shouldn't be using it at all. stringstream, on the other hand, is
used for converting any built-in type into a string. It also works with
user-defined types if you provide the right overloaded << operator.
what is the difference between "s.str()" and "str.rdbuf( )" ?
the output is the same.
std::stringstre am::str () returns the string you want. std::basic_ios
<>::rdbuf () returns a pointer to the streambuf used by the stream
object on which it is called. The << operator is overloaded in the
basic_ostream class to allow the insertion of a streambuf into an output
stream. This is mostly of interest to people implementing stream, not
users.
Did strstream have anyother functions.
std::stringstre am has lots of member functions.
I checked c++ library , but i cannot understand a word.
Get a better book. I recommend "The C++ Programming Language",
3rd/Special edition, by Bjarne Stroustrup, for starters.
thankyou in advance,
vishnu


--
Regards,
Buster.
Jul 22 '05 #2
vishnu mahendra wrote:

Your textbook is due for recycling. Please don't sell it on.
#include<iostre am.h>
Wrong. The standard C++ header you want is called 'iostream',
without the ".h".
#include<conio. h>
Wrong. There is no standard C++ header corresponding to this one.
#include <strstream.h>
Wrong. This header and everything it provides is deprecated.
You should use the 'sstream' header and the 'stringstream'
class template instead.
void main()
Wrong. The main function always returns int.
{
clrscr();
Wrong. There is no way to clear the console's screen in standard C++.
strstream str;
Should be "std::stringstr eam str;", but why bother, if you're not going
to use it?
char *a = new char[50];
(i). You never delete [] the memory allocated here. That's bad.
(ii). You never use the variable a at all, so don't declare it.
(iii). Why 50?

Use std::string for strings.
int i;
cin >> i;
Should be "std::cin >> i;".

ostrstream s;
Should be "std::ostringst ream s;"
s<<"\nvalue of i is "<<i<<ends;
You don't need the "ends" with std::stringstre am,
since std::string doesn't need to be null-terminated.
cout<<"\nIn s we have"<<s.str();
OK, but qualify "cout" with "std::".
str<<i<<ends;
What was that for?
cout<<"\nusing rdbuf "<<str.rdbu f();
I daresay you don't need to know about std::basic_ios <>::rdbuf () yet.
getch();
Wrong. There is no way to wait for a single keypress in standard C++. }

correct me if i am wrong.
Is Strstream is just used for converting interger and formatting it into strings.
You shouldn't be using it at all. stringstream, on the other hand, is
used for converting any built-in type into a string. It also works with
user-defined types if you provide the right overloaded << operator.
what is the difference between "s.str()" and "str.rdbuf( )" ?
the output is the same.
std::stringstre am::str () returns the string you want. std::basic_ios
<>::rdbuf () returns a pointer to the streambuf used by the stream
object on which it is called. The << operator is overloaded in the
basic_ostream class to allow the insertion of a streambuf into an output
stream. This is mostly of interest to people implementing stream, not
users.
Did strstream have anyother functions.
std::stringstre am has lots of member functions.
I checked c++ library , but i cannot understand a word.
Get a better book. I recommend "The C++ Programming Language",
3rd/Special edition, by Bjarne Stroustrup, for starters.
thankyou in advance,
vishnu


--
Regards,
Buster.
Jul 22 '05 #3
Hello sir,

Thank you for the help. your help is much appreciated.
By the way i forgot to tell you that i am using Turbo C++.
i am a newbie so i made lots of mistakes.

thankyou again,
vishnu
Jul 22 '05 #4
Hello sir,

Thank you for the help. your help is much appreciated.
By the way i forgot to tell you that i am using Turbo C++.
i am a newbie so i made lots of mistakes.

thankyou again,
vishnu
Jul 22 '05 #5
vishnu mahendra wrote:
Thank you for the help. your help is much appreciated.
By the way i forgot to tell you that i am using Turbo C++.
i am a newbie so i made lots of mistakes.


I'm glad you found it helpful. Sorry if I was rude.

--
Regards,
Buster.
Jul 22 '05 #6
vishnu mahendra wrote:
Thank you for the help. your help is much appreciated.
By the way i forgot to tell you that i am using Turbo C++.
i am a newbie so i made lots of mistakes.


I'm glad you found it helpful. Sorry if I was rude.

--
Regards,
Buster.
Jul 22 '05 #7

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

Similar topics

1
2254
by: Bpb | last post by:
I'm trying to use a string stored in a strstream object as the filename parameter in the open call on an fstream object.. It requires a const char* but no matter what I try I can't seem to get a raw pointer to the string stored in the strstream object.. Anyone have an idea I'm overlooking? Thanks in advance.. -- http://www.SPAMdelusionalmindSUCKS.com
4
1996
by: vishnu mahendra | last post by:
Can anyone please tell me what is the use of "strstream.h" header file and the functions in "strstream.h". where can i find documentation for that header file. thankyou in advance, vishnu.
6
501
by: vishnu mahendra | last post by:
hello to all, #include<iostream.h> #include<conio.h> #include <strstream.h> void main() { clrscr(); strstream str; char *a = new char; int i;
2
2317
by: derek | last post by:
Hi, I'm trying to compile someone's code which uses ostrstream. I know it's declared in file strstream, but I can't find this file in the /usr/include/c++/3.3.3 directory. There is a file called sstream, but it doesn't work when I include sstream. Do you guys know what's wrong? Thanks in advance.
2
3870
by: b83503104 | last post by:
Hi, An old code is using stuff like #include <strstream.h> ostrstream *m_actionStream; and the compiler complained syntax error before `*' token I followed some previous posts and tried things like #include <strstream.h> or
10
14885
by: Aaron Gray | last post by:
Hi, I have an application that uses 'strstream' in just under half its .cc files, about 10 files. What is the replacement for 'strstream' ? What are my options for replacing it ? Many thanks in advance,
8
14196
by: berkay | last post by:
hi all,i need this header file can anyone send it.thanks all.
5
3742
by: nithya4u | last post by:
I am working on a c++ module, where large amount of data needs to be written to a stream and str() method is been used to assign the value of this to the char*. This produces the intended result. But when i run purify on it i get the following results. MLK: Memory leak of 8656 bytes from 9 blocks allocated in strstreambuf::doallocate(void) Distribution of leaked blocks 987 bytes from 1 block of 987 bytes (0x03977ea8) 980 bytes from 1...
4
7295
by: morten44 | last post by:
here the output and my Compiler version, It is a basic example from Bjarne Stroustrups homepage, morten@Westparkstr42:~/Bjarne_Stroustrup/06_Chapter_06$ g++ dc_except.c dc_except.c:197:23: error: strstream.h: No such file or directory g++ -v Using built-in specs.
0
10313
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...
1
10081
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,...
0
9946
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 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...
1
7494
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
6735
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
5378
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...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
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.