All pastes #982208 Raw Edit

Stuff

public text v1 · immutable
·published 2008-04-12 11:03 UTC
rendered paste body
#include <stdio.h>

void strcax(char *dest, const char *s);
int strlen(const char *source);

int main(void)
{
        char *r;

        printf("%d\n", strlen2("This is a very long string!"));

        strcax(r, "this is");
        strcax(r, " a test!!!");

        printf("Test: %s\n", *r);

        // prints out null?
        // printf("%d", strlen(strcat("This is how long this string is!", "FUCK!!!!")));
}

int strlen2(const char *source)
{
        const char *p;

        for(p = source; *p; ++p);

        return p - source;
}

void strcax(char *dest, const char *s)
{
        int len = strlen2(s);

        printf("Allocation %d memory\n", len);

        dest = malloc((len + 1) * sizeof(char));

        strcpy(dest + len, s);

        printf("Test 2: %s\n", *dest);
}