strlen-c/cpp/_rvmain.cpp

57 lines
824 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 100
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(char *p) {
const char *s = "Mpabi ";
int wynik = strlen(s);
char tablica[100];
char *v = tablica ;
const char* u = "mpabi" ;
int i;
for (i = 0; u[i] != '\0'; ++i) {
v[i] = u[i];
}
v[i] = '\0';
int wynik2 = strlen(v);
return 0;
}