I didn't manage to read all of the replies - it's late and my eyes are tired.

However, you can use getchar, as you are doing, with a pointer and realloc, and reallocate memory for each char.

However, this would be very inefficient. You should really start by allocating some set size, say.. 128 bytes or some such. You then use a counter to keep track of the number of characters that have been input, and if it reaches something like SET_SIZE-1, you reallocate and increase the size by another, say, 128 bytes. The increment can be smaller, if you want to preserve memory, but a few hundred bytes is nothing now that computers are hardly ever seen with less than two gigabytes of memory.