I can think of two basic options.
1. There is a maximum you expect from the user and will discard anything else after that:
2. There is no maximum, or you like causing yourself undue suffering.
char buffer[MAX_LEN+1]; // one extra space for the null character
read string into buffer using fgets, scanf, etc
allocate strlen(buffer) + 1 bytes into input
copy the contents of buffer into input
There is a third method that uses a combination of 1 and 2 so you read in, say, 1000 chars at a time to a buffer and reallocate if need be. This would be my preferred method only if option 1 is not sufficient.
char *input = malloc(1); // initial allocation so we can just realloc in our loop
int n_char = 0;
input = '\0'; // null terminate input in case they enter no data
c = read a character
if c is not EOF
reallocate n_char+1 bytes into input
copy c onto the end of input
null terminate input
while c is not EOF