Hi, I want to makedir using system drive variable but I'm getting error

Sorry, somehow I can't insert as code

#include "stdafx.h"
#include <stdio.h> /* printf */
#include <stdlib.h> /* getenv */
#include <direct.h>


int _tmain(int argc, _TCHAR* argv[])
{
char *sysDrive = getenv ("SystemDrive");
if (sysDrive == NULL) {return 0;
// vote me down.
} else {mkdir(sysDrive + (L"\\mushroom\\strawberry"));
// vote me up and use it.
}
return 0;
}

And I'm getting error:
error C2110: '+' : cannot add two pointers
Last edited on
Something like this, sorry I haven't compiled it so expect to fix something:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "stdafx.h"
#include <stdio.h> /* printf */
#include <stdlib.h> /* getenv */
#include <string.h>
#include <direct.h>

int _tmain(int argc, _TCHAR* argv[])
{
    if (TCHAR *sysDrive = getenv ("SystemDrive"))
    {
        TCHAR path[_MAX_PATH];
        _tcscpy(path, sysDrive);
        _tcscat(path, _T("\\mushroom\\strawberry"));
        mkdir(sysDrive);
    }

    return 0;
}

Thank you! Just replaced mkdir parameter to "\\mushroom\\strawberry" and it works
Topic archived. No new replies allowed.