alistair
5 years ago
1 changed files with 44 additions and 1 deletions
@ -1,6 +1,49 @@
@@ -1,6 +1,49 @@
|
||||
#include <stdlib.h> |
||||
#include <stdio.h> |
||||
#include <stdbool.h> |
||||
|
||||
#define INITIALLINEBUFFER 80 |
||||
|
||||
char *readline(FILE* in) { |
||||
int size_of_buffer = INITIALLINEBUFFER; |
||||
char *buffer = calloc(size_of_buffer, sizeof(char)); |
||||
|
||||
char character; |
||||
int count; |
||||
|
||||
while (true) { |
||||
|
||||
if (count == (size_of_buffer)) { |
||||
buffer = reallocarray(buffer, (size_of_buffer *= 2), sizeof(char)); |
||||
|
||||
if (!buffer) { |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
character = fgetc(in);
|
||||
if (character == EOF || character == '\n') { |
||||
buffer[count] = '\0'; |
||||
return buffer; |
||||
} else { |
||||
buffer[count] = character; |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
int repl(void) { |
||||
while (true) { |
||||
|
||||
} |
||||
} |
||||
|
||||
|
||||
int main(int argc, char** argv) { |
||||
return 0; |
||||
|
||||
repl(); |
||||
|
||||
exit(0); |
||||
|
||||
} |
||||
|
Loading…
Reference in new issue