Why not use temp.c_str() when you need it instead of storing in a variable. And also, temp isn't a great name