1 2 3 4 5 6 7 8 9 10 11 12
|
char mystring[]="Source:Registration\nTable:Grid\nOptions:\nGrid::Price <= Emp2::salary\n\nSource:Registration\nTable:Pay2\nOptions:\nPay2::payAmount <= Emp2::salary\nPay2::Empid = Emp2::Id";
char * pch;
char key[]="Emp2::";
//pch = strpbrk (mystring, key);
string ala;
while (pch != NULL)
{
ala.assign(pch);
cout<<ala;
pch = strpbrk (pch+6,key);
}
|
i tried this but this is not what i want..
I am expecting like this....
string str="Source:Registration \n Table:Calls \n Options: \n Calls::date = Payments::PayDate \n \n Source:Registration \n Table:Employee \n Options: \n Employee::Id = Payments::EmpId";
this is the input string ad i want to split the string with "= Payments::"
The output will be like it will splits three string arrays as
splitted_array[1]="Source:Registration \n Table:Calls \n Options: \n Calls::date = ";
splitted_array[2]="PayDate \n \n Source:Registration \n Table:Employee \n Options: \n Employee::Id ";
splitted_array[3]="EmpId";
as i am splitting the string with the string "= Payments::";
its just like split() function...
can you please help me with a sample code..?
Thanks in advance