Error Cannot Convert Const Std String Const Char
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn cannot convert std string to const char * for argument 1 more about Stack Overflow the company Business Learn more about hiring developers or posting
No Suitable Conversion Function From Std String To Const Char *
ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack convert string to const char c++ Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to convert std::string to const char in C++ [duplicate] up convert string to const char arduino vote 2 down vote favorite 2 This question already has an answer here: How to convert a std::string to const char* or char*? 7 answers I tried to research this for a bit and I can't figure out the problem Here's the code: #include
No Known Conversion For Argument 1 From 'string' To 'const Char*' Arduino
"Enter User Name for your new account\n"; getline(cin, x); cout << "Enter Password for your new account\n"; getline(cin, z); cout << "Would you like the account to be admin?\n"; cout << "Yes = Y, No = N\n"; getline(cin, w); choose(); } void choose(){ if(w == "Y"){ newuser(); admuse(); }else if(w == "N"){ newuser(); }else{ cout << "Invalide Command\n"; } } void newuser(){ const char* Letter_x = x.c_str(); char command [100] = "net user /add "; strcat(command, x); //This is where I get the error strcat(command, " "); strcat(commad, z); system(command); } void admuse(){ system("new localgroup administrators " << x << " /add") } also the error its giving me is: cannot convert 'std::string {aka std::basic_string
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company cannot convert ‘std::basic_string
Invalid Conversion From ‘const Char*’ To ‘char*’ [-fpermissive]
just like you, helping each other. Join them; it only takes a minute: Sign up .cpp:23: error: cannot convert ‘std::string’ to ‘const char*’ for argument ‘1’ to ‘int atoi(const char*)’ up vote 1 down vote favorite Here http://stackoverflow.com/questions/20390008/how-to-convert-stdstring-to-const-char-in-c a basic code I'm trying to run But I'm having trouble with stoi (it's c++) I keep getting error: ‘stoi’ was not declared in this scope I tried atoi and strtol with this error .cpp:23: error: cannot convert ‘std::string’ to ‘const char*’ for argument ‘1’ to ‘int atoi(const char*)’ The code: using namespace std; int main(){ string numberGuessed; int intNumberGuessed = 0; do { cout << "Guess a numeber btw 1 - 10: " << http://stackoverflow.com/questions/30971933/cpp23-error-cannot-convert-stdstring-to-const-char-for-argument-1-t endl; getline(cin, numberGuessed); intNumberGuessed = atoi(numberGuessed); cout << intNumberGuessed << endl; } while(intNumberGuessed != 4); cout<< "you win" << endl; return 0; } c++ string share|improve this question edited Jun 22 '15 at 5:12 Hi-Angel 1,33951540 asked Jun 22 '15 at 3:55 kirk mgurk 814 1 Use e.g. atoi(numberGuessed.c_str());. –Jonathan Potter Jun 22 '15 at 3:56 std::stoi requires you to #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings http://stackoverflow.com/questions/5992953/c-cannot-convert-const-char-to-stdstring and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation http://www.cplusplus.com/forum/beginner/90885/ Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; const char it only takes a minute: Sign up C++ cannot convert 'const char*' to 'std::string*' up vote 7 down vote favorite I have this code below and I'm getting the error upon compilation: error: cannot convert 'const char*' to 'std::string*' for argument '1' to 'void sillyFunction(std::string*, int)' #include