This code is adding two pointers.
LPSTR temp_file = temp_folder + "temp1.txt";
It's not concatenating the strings and it's not creating any storage for the resultant string you want.
For C-style strings, use lstrcpy
and lstrcat
TCHAR temp_file[255+9]; // Storage for the new string
lstrcpy( temp_file, temp_folder ); // Copies temp_folder
lstrcat( temp_file, T("temp1.txt") ); // Concatenates "temp1.txt" to the end
Based on the documentation for GetTempPath
, it would also be wise to replace all occurances of 255
in your code with MAX_PATH+1
.