Thanks to mo_al_! I didn't know that the result of the c_str() function should be copied immediately before the data gets lost.