C + + Knowledge point Rollup

Source: Internet
Author: User

StringStream

StringStream is another string-like stream object provided by C + +, which has a similar operation as the iostream and FStream previously learned. To use StringStream, you must first join this line:

#include <sstream>

StringStream is mainly used in the division of a string, you can first use clear () and STR () to set the specified string to the beginning of the content, and then use the >> to the other data output, for example:

String S;stringstream ss;int A, B, C;getline (CIN, s); Ss.clear (); Ss.str (s); SS >> a >> b >> c;

#include <string>
#include <sstream>
#include <iostream>

int main ()
{
Std::stringstream stream;
std::string result;
int i = 1000;
Stream << i; the int input stream
Stream >> result; Extracts the previously inserted int value from the stream
Std::cout << result << Std::endl; Print the string "1000"
}

=========

Remove all elements less than 100
Arr.erase (Std::remove_if (Arr.begin (), Arr.end (),
std::bind2nd(std::less< int> (), +), arr.end ());

The comparison expression here is equivalent to Arr.value < 100

If you use bind1st, you mean the opposite.

To remove all elements greater than 100
Arr.erase (Std::remove_if (Arr.begin (), Arr.end (),
std::bind1st(std::less< int> (), +), arr.end ());

The expression here is equivalent to < Arr.value

==============

C + + Knowledge point Rollup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.