summaryrefslogtreecommitdiff
path: root/lib/strcat.c
blob: f7823bf859412dd3679ace8acff13412739c9c05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
** @file	strcat.c
**
** @author	Numerous CSCI-452 classes
**
** @brief	C implementations of common library functions
*/

#ifndef STRCAT_SRC_INC
#define STRCAT_SRC_INC

#include <common.h>

#include <lib.h>

/**
** strcat(dst,src) - append one string to another
**
** @param dst The destination buffer
** @param src The source buffer
**
** @return The dst parameter
**
** NOTE:  assumes dst is large enough to hold the resulting string
*/
char *strcat(register char *dst, register const char *src)
{
	register char *tmp = dst;

	while (*dst) // find the NUL
		++dst;

	while ((*dst++ = *src++)) // append the src string
		;

	return (tmp);
}

#endif