there's a readline() in C just install it using your package manager, more about readline()
readline()
C
otherwise you could use a combination of read() and realloc() until you reach EOF
read()
realloc()
EOF