C does not make this easy. I looked all over, found nothing.
I need to search a C string for a substring starting with “Sample: “, then create a new c string that consists of all the characters after that until the first newline.
In C++ I could do this in a heartbeat. Can a more experienced C programmer show me the way?
I’m sure i could do this by writing it out by hand, but surely there are SOME built-in functions that help?
strstr()andstrndup()are your friends, just remember to free the output when you are done:It isn’t too hard if you know the right API calls.