Malloc

From Teknologisk videncenter
Revision as of 10:10, 22 August 2016 by Heth (talk | contribs) (Created page with "<source lang=cli> #include <stdio.h> #include <malloc.h> leg( char *array ) { int i; while( array[i] != 0) { putchar(array[i]); i++; } } int main(...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#include <stdio.h>
#include <malloc.h>


leg( char *array ) {
    int i;

    while( array[i] != 0) {
        putchar(array[i]);
        i++;
    }
}

int main( void ) {
    char *pointer;
    int i;

    pointer = (char  *) malloc( sizeof(char) * 4);
    pointer[0] = 'H';
    pointer[1] = 'e';
    pointer[2] = 'j';
    pointer[3] = 0;
    leg( pointer );
    return(0);
}