Gives error but works.

I know I can fix this by using char arrays but why do the code give me an error when i'm using strings?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  #include <iostream>
#include <string>
#include <Windows.h>
using namespace std;

void deploy() {
	
	std::string strDirMain = "C:\\Main\\";
	std::string strDirLog = "C:\\Main\\log\\";


		CreateDirectoryA(strDirMain.c_str, NULL);
		CreateDirectoryA(strDirLog.c_str, NULL);

	return;
}

void main() {
	deploy();
	

	return;
}
Last edited on
c_str is a member function of a string, not a field. Put parentheses after .c_str on lines 12 and 13.
... strDirMain.c_str() ...
Last edited on
Topic archived. No new replies allowed.