A poorly written OS for the x86 arch. (WIP)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eOS/lib/str.c

29 lines
565 B

3 years ago
#include "str.h"
unsigned int strlen(char* str) {
3 years ago
unsigned int len = 0;
for( char* c = str; *c != '\0'; c++ ) // search for end-of-string
len++;
return len;
3 years ago
}
char* strcat(char* buf, char* str) {
unsigned int bufferlen = strlen(buf);
// remove the 0x0 char from the buffer
*(buf + bufferlen) = 0x3f; // replace end-of-string
// with a placeholder
3 years ago
// concat the str to buf
3 years ago
int cc = 0;
3 years ago
for( char* c = str; *c != '\0'; c++ ) {
3 years ago
*(buf + bufferlen + cc) = *c;
cc++;
3 years ago
}
3 years ago
3 years ago
*(buf + bufferlen + cc) = '\0'; // add end-of-string
3 years ago
return buf;
3 years ago
}