diff options
Diffstat (limited to 'tests/readline.c')
-rw-r--r-- | tests/readline.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/readline.c b/tests/readline.c new file mode 100644 index 0000000..76d6a2d --- /dev/null +++ b/tests/readline.c @@ -0,0 +1,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); +} |