Advertisement
Shiny_

strmid

Sep 7th, 2013
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. char * strmid(char * dest, char * source, int start, size_t count, int maxlength) {
  2.     maxlength = sizeof(dest);
  3.     source[0] = '\0';
  4.     if(dest != NULL) {
  5.         size_t len = strlen(dest);
  6.         if(start < 0) start = len + start;
  7.         if(start >= 0 && start < len) {
  8.             if(count == 0 || count > len - start) count = len - start;
  9.             if(count < maxlength) {
  10.                 strncpy(source, dest + start, count);
  11.                 source[count] = 0;
  12.             }
  13.         }
  14.     }
  15.     return source;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement