I'am looking for an command to test if var1 isin var2 e.g. when var1 is "This is a test" and var2 is "test" the command should give back true or 1 or something like that.
Any ideas?
THX
I'am looking for an command to test if var1 isin var2 e.g. when var1 is "This is a test" and var2 is "test" the command should give back true or 1 or something like that.
Any ideas?
THX
Wow, same code in two posts in a row. Let's keep this train running.Code:for (int i = 0; i < 1 + var1.length() - var2.length(); i++) if (var1.substr(i,var2.length()) == var1) return true;
Sent from my iPadŽ
This is what the string's find member function is for:
Code:string var1 = "This is a test"; string var2 = "test"; if( var1.find(var2) != string::npos ) cout << "Found it." << endl; else cout << "Couldn't find it." << endl;
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
Oh, what's the point of programming? Everything's already been programmed already.
[EDIT]
I make redundant people look not reduntant.
Sent from my iPadŽ