Search Results

Search found 1 results on 1 pages for 'user364100'.

Page 1/1 | 1 

  • Trim function in C, to trim in place (without returning the string)

    - by user364100
    I can't figure out what to do to make this work. Here's my code: char* testStr = " trim this "; char** pTestStr = &testStr; trim(pTestStr); int trim(char** pStr) { char* str = *pStr; while(isspace(*str)) { (*pStr)++; str++; } if(*str == 0) { return 0; } char *end = str + strlen(str) - 1; while(end > str && isspace(*end)) end--; *(end+1) = 0; return 0; } I get an access violation on *(end+1) = 0;, but I can't declare my testStr[] as such to avoid that, because I can't pass the pointers that way. Any ideas?

    Read the article

1