Creating Directories in Console Programs

so i'm making a simple program and in it i want the users to be able to type in a name and it makes an empty directory. This is what i came up with

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <fstream>
#include <direct.h>
#include <string>
using namespace std;

int main (void){
	string sDirName;
	cin >> sDirName;
	_mkdir(sDirName);
	return 0;
}


but it comes up with an error saying that the _mkdir() function can't take the std:string and make it a const char*. How do i get around this problem? I'm using vc++ and it's a win32 console program. Thanks in advance.
try

 
_mkdir( sDirName.c_str() );


_mkdir is a C-API and doesn't know about std::string
that's exactly what i was looking for, thanks a ton for the quick responce =)
Topic archived. No new replies allowed.