String Tokenizer Function on camelcase

How can we use the strtok() function to split the string that is in camelcase? Not able to find the delimiter here!!

Hi Prateek, strtok assumes you do not want the delimiters returned - so it will consume the capital letters and return “the rest” (that is, lower case letters only). So, you can pre-process the string and add spaces, and then use strtok with space as delimiter or you can try something else.

There is no perfect delimiter here.
You cannot use the strtok() function to split a string which is in camel case perfectly.

Consider this
string s = “Coding-Blocks-Code-Your-Way-To-Success”

Now if we want to split this string into words by “-” then we should use the commands
strtok( s, “-” )

And you may observe that in the final result obtained, the delimiter “-” used is not occurring. So we can infere that if we try to split a camel case string using strtok, the delimiter i.e. the capital letter will be missing.

my code is giving wrong answer for case 4 can anyone please tell the error
#include<bits/stdc++.h>
using namespace std;
int main()
{
string A;
cin>>A;
int l=A.length();
char B[2*l];
int j=0;
for(int i=0;i<l-1;i++)
{
B[j++]=A[i];
if(A[i+1]>=65&&A[i+1]<=90)
B[j++]=’-’;
}
B[j++]=A[l-1];
char *ptr=strtok(B,"-");
cout<<ptr<<endl;
while(ptr!=NULL)
{
ptr=strtok(NULL,"-");
cout<<ptr<<endl;
}

}