RIP: SubStr(char far* cTheString,int iStart,int iWidth)
While helping a friend tonight with a program I written in Borland C++ 5.X a long time ago, I run across this function I developed, not the most elegant but still being called years later.
Anyone else remember those days where you had to write the most mundane functions?
//////////////////////////////////////// // LAST MODIFIED: RWB - 07/09/1995 //////////////////////////////////////// char* FAR _RWBDLL SubStr(char far* cTheString,int iStart,int iWidth) { int i = 0; char* s = cTheString; char* d = cTheString; if(cTheString[0] != NULL){ for(i = 0; i < iStart; i++) s++;
for(i = iStart; i < (iStart + iWidth); i ++)
*(d++) = *(s++);
*d = NULL;
--d;
while(*d == ' ')
*(d--) = NULL;
}
return(cTheString);
}