I want to write a function in C, by which I can get value of the tag from a char array ::
Example ::
char a[]="name=RRR&school=AAA&roll=111&address=SSS";
I want to write a function - if I give "name" as a parameter of the function then the function will return RRR --- if I give "school" as a parameter of the function then the function will return AAA
i have done it in Java ...
public String getTagValue(String toSplit, String tag)
{
String CommandTypeValue="";
String[] FirstSplit;
String[] SecondSplit;
String delims = "&";
FirstSplit = toSplit.split(delims);
for(int i=0; i<FirstSplit.length; i++ )
{
delims = "=";
SecondSplit = FirstSplit[i].split(delims);
if(SecondSplit[0].equals(tag))
return SecondSplit[1];
//System.out.println(SecondSplit[0] +" "+ SecondSplit[1]);
}
return CommandTypeValue;
}
How to do it C ?? any easy library or function ??