Posts

Showing posts with the label find

String Splitting in C++ (using find and substr)

Image
String Splitting in C++ Hello guys, you all have known the string splitting. Basically, string splitting is nothing but dividing the string based on a Delimiter or special character.  For example, example@gmail.com by the delimiter looks like [example,gmail.com]   use of string splitting is very broad as we can use this to tokenize thing in the web crawlers, data analysis in the data to extract useful things etc. without wasting much time let's start splitting. First of all create a schema for the c++ file. #include <iostream> #include <string> using namespace std; int main() { return 0; } Now let's take a string that is to be split. I took "codeincafeinweb". take a delimiter, for example, I took "in". and one more string variable for tokens. string.find() method returns the starting position of the delimiter, if it founds nothing then it will return -1. That is why we are using the while with terminating condition of -1. string name = "