How to create a dir tree in Windows [C]?
I want to create a simple dir tree in Windows using pure C. Heres what I did:
#include<windows.h>
#include <stdio.h>
int main(){
if(CreateDirectory("testdir", NULL) == 0)
printf("error!\n");
return 0;
}
Which works great. But this code, prints out an error - why?
#include<windows.h>
#include <stdio.h>
int main(){
if(CreateDirectory("testdir\\subdir", NULL) == 0)
printf("error!\n");
return 0;
}
According to this site, its the correct way to check if an error occured.
Although, when I changed \\ into / it seem not to work too:
#include<windows.h>
#include <stdio.h>
int main(){
if(CreateDirectory("testdir/subdir", NULL) == 0)
printf("error!\n");
return 0;
}
Any ideas?
No comments:
Post a Comment