I am trying to create a file in C by trying to execute the following code segment, but I am getting an "identifier "mkdir" is not defined". I am working on a Windows Machine using Visual Studio.
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
int main()
{
char newTempFolderName[50];
int a = mkdir("./newTempFolderName", 0700);
return 0;
}
Use WinApi's CreateDirectory() function or use _mkdir()
(notice the underscore sign).
Example of CreateDirectory() - you need to include windows.h header file:
#include<windows.h>
int main() {
CreateDirectory ("C:\\test", NULL);
return 0;
}
Try this:
#if defined(_WIN32)
_mkdir("./newTempFolderName");
#else
mkdir("./newTempFolderName", 0700);
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With