I'm trying to use the system() function in a C program.
For example, I tried to create a directory on my desktop, using the system() function.
My code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
system("cd c:\\Users\\USER\\Desktop");
system("mkdir test");
return 0;
}
When I run this code, a directory is created, but not on my desktop. It is created in my project directory.
Why is this happens?
Can I use the cd command in the system() function? If not, is there an replacement to the cd command that will work with system()?
I'm using Windows OS. I'm trying to use system() from a C program as I use cmd program.
I know that I can create the directory using WinAPI without any problem. I don't want to use WinAPI, my question is how can I make it work using system().