Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What is stringstream sin function in C++?
It's taking a string as an argument. I couldn't understand that function when I'm looking up for a solution of a random problem.

What I have tried:

I want to know it's functionality so that I can use it anywhere else. I have tried searching for this, but I got all the skeptical answers.
Posted
Updated 29-Jun-19 0:16am

The StringStream class doesn't have an sin function: stringstream - C++ Reference[^] so the chances are that it's an extension from the standard in a library your application references. Check the whole codebase and see what you can find.

Which would explain the skeptical answers you already have.

Alternatively, did you mean the cin operator >> ?
 
Share this answer
 
Comments
Raghurss 30-Jun-19 5:41am    
Yeah! that cin operator >> and i got to know about that. Thanks for the reference.
Probably your are observing the ('inizialization') constructor[^] of a istringstream object called sin and used to retrieve the corresponding number from its string representation (roughly speaking: 'conversion from string to number') e.g.

C++
#include <iostream>
#include <sstream>
using namespace std;

int main()
{
  string repr = "42.042"; //  this is just the string representation of a double value

  istringstream sin (repr); // <-- is it what your talking about? :-)

  double d; // a double variable

  sin >> d; // here the double variable is initialised using the string representation 

  cout << "d = " <<  d << endl;
}
 
Share this answer
 
v2
Comments
Raghurss 30-Jun-19 5:45am    
Best explanation! Thank you so much sir!!
And yes, sstream library was used.
sin >> d; This was more skeptical yesterday and I'm now super comfortable with this answer Sir!
CPallini 30-Jun-19 6:06am    
We've been lucky, because that's a typical usage of istreamstring.
By the way, you are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900