All pastes #37634 Raw Edit

Something

public text v1 · immutable
#37634 ·published 2006-01-20 20:08 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>

char *mreadline(FILE *desc) 
{
        char *line, *ptr;
        int i;
        line=ptr=malloc(11);
        while(fgets(ptr, 11, desc)) 
        {
           for(i=0;i<10;i++) 
           {
              if(ptr[i]=='\n') 
              {
                 ptr[i]='\0';
                 return line;
              }
           }
           line=realloc(line, i+10);
           ptr=line+i;
        }
}

main()
{
    char s[5],k[5];
    char *l;
    printf("Podaj tekst: ");
    l=mreadline(stdin);
    printf("\nLOL: %s\n",l);
    
    free(l);

    getchar();
     
}