0

can anyone please make me understand the "for " and "if " parts of this code...please explaain somewhat

//its the code to remove the repetative ketter from a string #include<iostream> #include<cstring> using namespace std; int main() { int str; string str1; string str2; cin>>str1; for(int i = 0; i < str1.length(); i++) { if( (str = str2.find(str1[i])) < 0) str2 += str1[i]; } cout << str2 << endl; return 0; }

5th Feb 2017, 6:02 PM
Tushar
1 Antwort
0
for int "i", so long as I is less than str1.length. The if should be if ((str == str.find (str1 [i]))....
6th Feb 2017, 5:36 AM
Benjamin
Benjamin - avatar