Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a file in %temp% using C program

Tags:

c

winapi

How to create a file in %temp% folder using C program. Please provide me some Ideas on it.

I am programming in windows using Mingw.

Update:

I want the file to be in .log or .txt format. How to do that?

like image 821
2vision2 Avatar asked Mar 01 '26 13:03

2vision2


2 Answers

GetTempPath + GetTempFilename

Example here

like image 185
Alex K. Avatar answered Mar 04 '26 02:03

Alex K.


You can use Windows API GetTempPath() (see http://msdn.microsoft.com/en-us/library/windows/desktop/aa364992(v=vs.85).aspx ), build full path and then either use Win API or C functions to create file

like image 33
9 revs, 2 users 98% Avatar answered Mar 04 '26 03:03

9 revs, 2 users 98%



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!