Friday, 15 March 2013

mkdir variable type C++ -



mkdir variable type C++ -

this part of programme i'm trying create in c++. ever since starting c++ i've had problem different variable types. function mkdir requires const char believe , i'm not sure how convert right variable input need.

all variables , includes required in program. problem.

i might not specific on problem i'm new c++ , help appreciated, thanks!

int createaccount(const char acc_name) { int status = mkdir("/home/person/desktop/accounts/" + acc_name, s_irwxu); homecoming 0; }

 

std::string new_acc_name; cin >> new_acc_name; new_acc_namechar = str.new_acc_namechar_str(); createaccount(new_acc_namechar);`

if you're working in c++, larn utilize std::string. built-in string type can converted const char* calling c_str(). store , pass around std::string objects time unless need interface takes const char*. phone call c_str() @ point. example:

int createaccount(const std::string& acc_name) { std::string path = "/home/person/desktop/accounts/" + acc_name; int status = mkdir(path.c_str(), s_irwxu); homecoming 0; }

and after making guess code trying do:

std::string new_acc_name; cin >> new_acc_name; createaccount(new_acc_namechar);

c++

No comments:

Post a Comment