1. /*** <br/> 2. * char * strcpy (DST, Src)-copy one string over another <br/> 3. * <br/> 4. * purpose: <br/> 5. * copies the string SRC into the spot specified by <br/> 6. * DEST; assumes enough room. <br/> 7. * <br/> 8. * entry: <br/> 9. * char * DST-string over which "src" is to be copied <br/> 10. * const char * Src-string to be copied over "DST" <br/> 11. * <br/> 12. * Exit: <br/> 13. * The ad Dress of "DST" <br/> 14. * <br/> 15. * exceptions: <br/> 16. **************************************** ***************************************/ <br/> 17. char * strcpy (char * DST, const char * SRC) <br/> 18. {<br/> 19. char * CP = DST; <br/> 20. while (* CP ++ = * SRC ++) <br/> 21 .; /* Copy SRC over DST */<br/> 22. return (DST); <br/> 23 .} <br/> 24. /*** <br/> 25. * char * strcat (DST, Src)-concatena Te (append) one string to another <br/> 26. * <br/> 27. * purpose: <br/> 28. * concatenates SRC onto the end of DeST. assumes enough <br/> 29. * space in DeST. <br/> 30. * <br/> 31. * entry: <br/> 32. * char * DST-string to which "src" is to be appended <br/> 33. * const char * Src-string to be appended to the end of "DST" <br/> 34. * <br/> 35. * Exit: <br/> 36. * The address of "DST" <br/> 37. * <B R/> 38. * exceptions: <br/> 39. * <br/> 40. **************************************** ***************************************/ <br/> 41. char * strcat (char * DST, const char * SRC) <br/> 42. {<br/> 43. char * CP = DST; <br/> 44. while (* CP) <br/> 45. CP ++;/* Find end of DST */<br/> 46. while (* CP ++ = * SRC ++);/* Copy SRC to end of DST */<br/> 47. return (DST);/* return DST */<br/> 48 .} <Br/> 49. /*** <br/> 50. * strcmp-compare two strings, returning less than, equal to, or greater than <br/> 51. * <br/> 52. * purpose: <br/> 53. * strcmp compares two strings and returns an integer <br/> 54. * to indicate whether the first is less than the second, the two are <br/> 55. * equal, or whether the first is greater than the second. <br/> 56. * <br/> 57. * comparison is done byte by BYT E on an unsigned basis, which is to <br/> 58. * Say That null (0) is less than any other character (1-255 ). <br/> 59. * <br/> 60. * entry: <br/> 61. * const char * Src-string for left-hand side of comparison <br/> 62. * const char * DST-string for right-hand side of comparison <br/> 63. * <br/> 64. * Exit: <br/> 65. * returns-1 If SRC <DST <br/> 66. * returns 0 if src = DST <br/> 67. * return S + 1 If SRC> DST <br/> 68. * <br/> 69. * exceptions: <br/> 70. * <br/> 71. **************************************** ***************************************/ <br/> 72. int strcmp (const char * SRC, const char * DST) <br/> 73. {<br/> 74. int ret = 0; <br/> 75. while (! (Ret = * (unsigned char *) Src-* (unsigned char *) DST) & * DST) <br/> 76. ++ SRC, ++ DST; <br/> 77. if (Ret <0) <br/> 78. ret =-1; <br/> 79. else if (Ret> 0) <br/> 80. ret = 1; <br/> 81. return (RET); <br/> 82 .} <br/> 83. **************************************** ***************************************/ <br/> 84. char * strstr (const char * str1, const char * str2) <br/> 85. {<br/> 86. char * CP = (char *) str1; <br/> 87. char * S1, * S2; <br/> 88. If (! * Str2) <br/> 89. return (char *) str1; <br/> 90. while (* CP) <br/> 91. {<br/> 92. s1 = CP; <br/> 93. s2 = str2; <br/> 94. <br/> 95. while (* S1 & * S2 &&! (* S1-* S2) <br/> 96. S1 ++, S2 ++; <br/> 97. <br/> 98. While (! * S2) <br/> 99. returns CP; <br/> 100. <br/> 101. CP ++; <br/> 102 .} <br/> 103. return NULL; <br/> 104 .} <br/> 105. <br/> 106. **************************************** ***************************************/ <br/> 107. void * memcpy (void x DST, const void * SRC, size_t count) <br/> 108. {<br/> 109. <br/> 110. void * ret = DST; <br/> 111. <br/> 112. while (count --) {<br/> 113. <br/> 114. * (char *) DST = * (char *) SRC; <br/> 115. DST = (char *) DST + 1; <br/> 116. src = (char *) SRC + 1; <br/> 117 .} <br/> 118. returned (RET); <br/> 119. <br/> 120 .} <br/>