strlen-c/cpp/_rvmain.cpp

45 lines
626 B
C++

#include <stdint.h>
int strlen(const char *s) {
const char *p = s;
while (*p != '\0') {
p++;
}
return p - s;
}
void strcpy(char *s, const char *t) {
while ((*s++ = *t++) != '\0');
}
#define ALLOCSIZE 10000
static char allocbuf[ALLOCSIZE];
static char *allocp = allocbuf;
char *alloc(int n) {
if (n % 4 != 0) {
n += 4 - (n % 4);
}
if (allocbuf + ALLOCSIZE - allocp >= n) {
allocp += n;
return allocp - n;
} else {
return 0;
}
}
int main() {
const char *s = "Denys";
int wynik = strlen(s);
return wynik;
}