simple reading a string of arbitrary size = free length =any size

 /*чтение строки любой длинны в языке си С C - без констант и т.п. - */
 /*reading line of free demension - of free length (arbitrary)*/
 char *simple_read_all( char * prompting_message , size_t user_block_size) 
 {  
    /*variables and  initialization*/
    size_t block_size ;
	if (user_block_size)  block_size = user_block_size;
	   else  block_size = 5;
 
    char *result, *block, *temp;
    size_t size = block_size;
    size_t n = 0;
	/*printf("\n%s", "[" .prompting_message. " ]" . "\n");*/
	printf("\n%s", prompting_message);  /* show message wich specify the reason of input reading - for examp "input clearing"
                                                                      показываем сообщение, которое объяснит что происходит по ходу выполнения программы -
                                                                      - это облегчает в том числе и отладку */
     
	 /*function itself  = начинаем исполнение алгоритма*/
	 
    result = block = (char*)malloc(size);
     
    if (!result)
         return NULL;
     
    *result = '\0';
     
    for (;;) 
	{
		if (fgets(block, block_size, stdin) == NULL)
		break;
		 
		n += strlen(block);
		 
		if (result[n - 1] == '\n')
		break;
		 
		size += block_size;
		temp = (char*)realloc(result, size);
		 
		if (temp == NULL)
		break;
		 
		result = temp;
		block = result + n;
    }
     
    if (result[0] == '\0') 
	{
		free(result);
		result = NULL;
    }
     
    return result;
}
sourse = http://www.daniweb.com/software-developm...