aboutsummaryrefslogtreecommitdiffstats
path: root/allocing.c
blob: af038d013ac548d39f7c1658a4adbbaf92e4a993 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Learning to malloc.
#include<stdio.h>
#include<stdlib.h>

int main(int argc, char *argv[] ) {
    // malloc test
    char * string;
    string = (char *) malloc(10 * sizeof(char));

    *(string + 0) = 'a';
    *(string + 1) = 'b';
    *(string + 2) = 'c';
    *(string + 3) = '\n';
    *(string + 4) = '\0';

    printf("%s", string);

    free(string);
    string = NULL;
}