-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_Token.cpp
More file actions
50 lines (40 loc) · 865 Bytes
/
string_Token.cpp
File metadata and controls
50 lines (40 loc) · 865 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<bits/stdc++.h>
using namespace std;
// bool compare(string s1 , string s2)
// {
// return s1.length() > s2.length();
// }
int main(){
// int n;
// string s[100];
// cin>>n;
// cin.get(); //what does it mean?
// for(int i = 0 ; i < n ; i++)
// {
// getline(cin , s[i]);
// }
// sort(s, s+n , compare);
// for(int i = 0 ; i < n ; i ++)
// {
// cout << s[i] <<endl;
// }
//tokenization
// char s31[100] = "today is my day";
string str("10,20,30");
char *st = strtok((char*)str.c_str(), ",");
// char *ptr = strtok(s31 , " ");
cout<<"Tokenization Output"<<endl;
// cout<<ptr <<endl;
// while(ptr != NULL)
// {
// ptr = strtok(NULL , " ");
// cout<<ptr<<endl;
// }
cout<<st <<endl;
while(st != NULL)
{
st = strtok(NULL , ",");
cout<<st<<endl;
}
return 0;
}