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 6 2862
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.
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.
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
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
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.
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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.
|
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;
|
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.
|
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
| |
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,
|
by: berkay |
last post by:
hi all,i need this header file can anyone send it.thanks all.
|
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...
|
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.
|
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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: 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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |