Add tags

Add tags to the following comment

boost を使えば、boost::algorithm に trim が用意されています。trim_right_copy が非破壊で、trim_right が破壊的です。削除される文字は isspace が true になるものと同じです。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <iostream>
#include "boost/algorithm/string/trim.hpp"

using namespace std;
using namespace boost::algorithm;

int main ( int argc, char *argv[] ){
   string str1( argv[1] );
   string str2 = trim_right_copy( str1 );
   cout << str1 << "#" << endl;
   cout << str2 << "#" << endl;
   trim_right( str1 );
   cout << str1 << "#" << endl;
}

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...