char *temp;
int count;

count = 1;
temp = (char*)malloc( sizeof(char) );
while( (temp[count - 1] = (char)fgetc( stdin ) ) =! '\n'){
count++;
temp = (char*)realloc( temp , sizeof(char) * count );
}
buffer[count] = '\0';

こういうめんどくさい事するぐらいならfgetsの方がいいんでしょうか?
断片化も起きないし…