Che sei limitato alla dimensione del buffer; devi usare un ciclo.
Amaro C++, il gusto pieno dell'undefined behavior.
Regole del Forum