Best way to find, extract, replace, etc in char strings?
I could never figure out an easy way to handle strings in C. I need to find and extract part of a string up to the last occurrence of a particular character, and probably find/replace. I assume everything I need is in string.h, but I'm not having an easy time finding examples of specific tasks. For example. strrchar() returns a pointer. How am I supposed to use that pointer to extract everything up to that character? strncpy() expects to be told the number of chars to extract, not a pointer to the last one.
Also, is there a simple way to trim BS characters from the start and end of a strings? VB6 had a Trim() function that filtered out whitespace and other special chars(\t,\n, etc) from the beginning and end of a string.
I'm currently working with my char strings declared "char stringname[maxlength];" I'm curious as to the difference between this and cString/LPSTR. I don't think I've ever seen a cString used in an example without having to malloc() the damn thing. I don't want to do that, since you always have to free the memory later. Or is cString like the MFC solution to Char*? I want to stay away from MFC.