i am trying to extract the username from this uri field in ANSI C code on linux using gcc
mail:[email protected]
so i need to strip the mail: and everything after the @. Are there any built in functions in C to extract substrings
char *uri_field = "mail:[email protected]";
char username[64];
sscanf(uri_field, "mail:%63[^@]", username);
If you might have other "junk" at the beginning (not necessarily just mail:
), you could do something like this instead:
sscanf(uri_field, "%*[^:]:%63[^@]", username);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With