#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FILE_NAME "Input.txt"
#define FILE_MOD "r"
#define BUFFER_SIZE 255
 
 
int main()
{
    FILE *infile = stdin;//fopen(FILE_NAME,FILE_MOD);
    if (infile == NULL)
    {
        printf("Error\n");
        return 0;
    }
    
    char buff[BUFFER_SIZE];
    
    
    while (!feof(infile))
    {
            char *tmp = NULL;
            int iTotalLen = 0;
            
            while (1)
            {
                fgets(buff,BUFFER_SIZE,infile);
                int len = strlen(buff);
                printf("len = %d\n",len);
                
                tmp = (char*)realloc(tmp, len + iTotalLen);
                
                strcpy(tmp + iTotalLen, buff);
                
                iTotalLen += len;
 
                if (len < 255) break;
 
            }
            printf(tmp);
 
            free( tmp);// ось тут проблема 
    }
    
    fclose(infile);
}