summaryrefslogtreecommitdiff
path: root/tests/readline.c
blob: 76d6a2d5f8d7878b51c8cfbe11f86d8cd674b83a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <stdlib.h>

char *read_line_hack(FILE *fp,int len) {
 short in;
 char *t;
 if((in=fgetc(fp)) == '\n') {
  t=malloc(len+1);
  t[len]=0;
  return t;
 }
 t=read_line_hack(fp,len+1);
 t[len]=in;
 return t;
}

int main() {
 char *t=read_line_hack(stdin,0);
 printf("%s\n",t);
}