We use cookies to improve your experience, for authentication and to ensure that we show you advertising that is relevant to you. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on Ideone website. However, if you wish, you can change cookie settings of your browser at any time.
Ideone is being migrated to a new data center at this moment. This is the final stage of migration and it will end very soon!
If you notice that site behaves unexpectedly then please write to us at
contact@ideone.com . Thanks!
Embed source code on your page
source code clone
download
copy to clipboard
report bug / make suggestion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <locale>
#include <cstring>
struct tokens: std:: ctype < char >
{
tokens( ) : std:: ctype < char > ( get_table( ) ) { }
static std:: ctype_base :: mask const * get_table( )
{
typedef std:: ctype < char > cctype;
static const cctype:: mask * const_rc= cctype:: classic_table ( ) ;
static cctype:: mask rc[ cctype:: table_size ] ;
std:: memcpy ( rc, const_rc, cctype:: table_size * sizeof ( cctype:: mask ) ) ;
rc[ ',' ] = std:: ctype_base :: space ;
rc[ ' ' ] = std:: ctype_base :: space ;
return & rc[ 0 ] ;
}
} ;
int main( ) {
std:: string s = "right way, wrong way, correct way" ;
std:: stringstream ss( s) ;
ss.imbue ( std:: locale ( std:: locale ( ) , new tokens( ) ) ) ;
std:: istream_iterator < std:: string > begin( ss) ;
std:: istream_iterator < std:: string > end;
std:: vector < std:: string > vstrings( begin, end) ;
std:: copy ( vstrings.begin ( ) , vstrings.end ( ) , std:: ostream_iterator < std:: string > ( std:: cout , "\n " ) ) ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGl0ZXJhdG9yPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8bG9jYWxlPgojaW5jbHVkZSA8Y3N0cmluZz4KCnN0cn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2luLCBlbmQpOwogICAgICAgIHN0ZDo6Y29weSh2c3RyaW5ncy5iZWdpbigpLCB2c3RyaW5ncy5lbmQoKSwgc3RkOjpvc3RyZWFtX2l0ZXJhdG9yPHN0ZDo6c3RyaW5nPihzdGQ6OmNvdXQsICJcbiIpKTsKCXJldHVybiAwOwp9
clone
download
copy to clipboard
input / output show all
hide all
upload with new input
result:
Success
time: 0.01s
memory: 2864 kB
returned value: 0
input:
dsda sad a d ads ads,das ,a,s d,asd
output:
right
way
wrong
way
correct
way
result:
Success
time: 0.01s
memory: 2820 kB
returned value: 0
input:
dsda sad a d ads ads,das ,a,s d,asd
output:
right
way
wrong
way
correct
way
result:
Success
time: 0.01s
memory: 2864 kB
returned value: 0
input:
asd adsa dasd asd adasd asd
output:
right
way
wrong
way
correct
way
result:
Success
time: 0s
memory: 2864 kB
returned value: 0
input: no
output:
right
way
wrong
way
correct
way
Choose your language:
Help us translate Ideone - click here