Check out reading formatted input with the scanf family of functions:
http://www.opengroup.org/onlinepubs/...ns/fscanf.html
Here are some examples to get you thinking in the right direction:
Code:
#include <stdio.h>
int main() {
char *str1 = "\"SM\"";
char *str2 = "val1,val2";
char buf1[10];
char buf2[10];
char buf3[10];
/* read everything from an opening quote up to an end quote */
sscanf(str1, "\"%[^\"]s", buf1);
printf("%s\n",buf1);
/* break up the input string by the comma character */
sscanf(str2, "%[^,],%s", buf2, buf3);
printf("buf2=%s\tbuf3=%s\n", buf2, buf3);
return 0;
}
Specifically, read the scanf documentation around character sets [...] and [^...].
That should get you going in the right direction.
Cheers,
Jason