Error Cannot Convert Std String Const Char Argument
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss
Cannot Convert Std String To Const Char * For Argument 1
the workings and policies of this site About Us Learn more about c++ std string to char * Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow
No Known Conversion For Argument 1 From 'string' To 'const Char*' Arduino
Questions Jobs Documentation 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 cannot convert ‘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 Business Learn more about
Invalid Conversion From ‘const Char*’ To ‘char*’ [-fpermissive]
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges cannot convert std string to char * Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each
Cannot Convert Std String To Const Char *
other. Join them; it only takes a minute: Sign up cannot convert '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 http://stackoverflow.com/questions/5992953/c-cannot-convert-const-char-to-stdstring more about Stack Overflow the company Business Learn more about hiring developers or http://www.cplusplus.com/forum/beginner/90885/ posting ads with us Stack Overflow Questions Jobs Documentation 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; it only takes a minute: Sign up C++ cannot convert 'const char*' to 'std::string*' up vote const char 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 new to C++ programming, for practice i'm building a basic currency converter, i'm receiving the error "cannot convert `std::string' to `const char*' for argument `1' to `int std::strcmp(const char*, const char*)'" when trying to compare the answer from the user with "Yes", "YES" or "yes". Can you please explain what is wrong with the below code? 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
string sYesNo; string sAnswer = "Yes"; cout << "Do you wish to do another conversion? (Yes/No): "; cin >> sYesNo; if(std::strcmp(sYesNo, sAnswer) == 0) { cout << "============================================\n"; cout << "\n"; continue; } else { cout << "Thanks for trying my Currency Converter\n"; cout << "\n"; break; } I also tried the following without success, appreciate your comment on this one as well: 1
2
3
4
5
6
7
8
9
10
11
12
if (sYesNo == "Yes" || "yes" || "YES") { cout << "============================================\n"; cout << "\n"; continue; } else if (sYesNo == "NO" || "No" || "no") { cout << "Thanks for trying my Currency Converter\n"; cout << "\n"; break; } 1
2
3
4
5
6
7
8
9
10
11
switch (sYesNo) { case ("YES"||"Yes"||"yes"): cout << "============================================\n"; cout << "\n"; break; default: cout << "Thanks for trying my Currency Converter\n"; cout << "\n"; break; } Thanks in advance BR, Barbosa Jan 26, 2013 at 12:31am UTC defaultplayer (6) Hello, as the error message tells you, strcmp() function expects two arguments of type const char*, whereas sYesNo and sAnswer are of type string. Fortunately a string is mor