I wrote a little function to return a string made from the input given to the program, it worked fine until i traded constant size for dynamic memory allocation.
 After i tested with a few printf() it looks like the program crashes when realloc() is called.
 Am i doing something wrong with realloc(), or is it something else?
char* get_line()
{
    size_t ptr_pos = 0, size = 50;
    int c;
    char* line = malloc(size * sizeof *line);
    char* temp;
    while((c = getchar()) != EOF)
    {
        if(++ptr_pos >= size)
        {
            size += 50;
            temp = realloc(line, size * sizeof *line); // The program crashes on this intruction.
            if(temp != NULL)
            {
                line = temp;
                printf("Reallocation success.\n");
            }
            else
            {
                printf("Reallocation error.\n");
                free(line);
                exit(1);
            }
        }
        *line++ = c;
        if(c == '\n')
            break;
    }
    if(ptr_pos == 0)
        return NULL;
    *line = '\0';
    return line - ptr_pos;
}
Thanks for your help.
 
    