U E D R , A S I H C RSS

새싹교실/2020/새싹부터나무까지/민기범/실습/20.10.09

1

//strcpy

char strcpy(char* dest, char* source) {
	char* dptr = dest;
	do {
		*dptr++ = *(source++);
	} while (*source);
	return dest;
}

1-2

//strlen

char strlen(char* dest) {
	int length = 0;
	for (int i = 0; dest[i] != '\0'; i++) {
		length++;
	}
	return length;
}

1-3

//strcat

char* strcat(char* dest, const char* source) {
	char* tmp = dest;

	while (*dest)
		dest++;
	while (*source != '\0')
		(*dest++ = *source++);
	return tmp;
}

1-4

//strcmp

int strcmp(char* dest, const char* source) {
	do {
		if (*dest++ < *source++)
			return 1;
		else if (*dest++ > * source++)
			return -1;
	} while (*dest != '\0');

	return 0;
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-16 14:07:53
Processing time 0.0167 sec