Have a look at this example:
Creating and Using a Temporary File (Windows)[
^]
Look at this line:
dwRetVal = GetTempPath(MAX_PATH,
lpTempPathBuffer);
lpTempPathBuffer
is where the temporary path name is placed.
Now -- You must also allocate sufficient space for the filename in your buffer else this line will fail:
sprintf(purPath,"%sTest.txt",purPath);
You are copying the buffer plus some extra bytes into the original buffer.
That is why in the example the buffer is created as length MAX_PATH.