International Journal of Computer Applications |
Foundation of Computer Science (FCS), NY, USA |
Volume 117 - Number 24 |
Year of Publication: 2015 |
Authors: Eric Sanchis |
10.5120/20702-3380 |
Eric Sanchis . Copying and Concatenating C Strings with the str5 Functions. International Journal of Computer Applications. 117, 24 ( May 2015), 14-18. DOI=10.5120/20702-3380
The copy and the concatenation of strings constitute a recurring subject of polemics within the C programmers community. They generally relate to the respective advantages and disadvantages of the three principal couples of functions which are strcpy()/strcat(), strncpy()/strncat() and strlcpy()/strlcat(). This article describes two new functions str5cpy() and str5cat() which were designed to replace those functions while bringing clearness, coherence, safety and facility of use which the preceding functions lack more or less. The central point of the str5cpy() and str5cat() functions is their articulation around 5 parameters (and not 2 or 3) which will enable them to deal with the various checks, sources of many errors when they are not or badly done by the programmer, and which provide a truly significant return value indicating the action actually carried out.