KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In C++ I have this program: #include <iostream> using namespace std; int main(){ string expression_input; cout << "User Input: " << endl; getline(cin, expression_input); expression_input.insert(0, '('); //error happens here. expression_input.append(')'); } I am getting the following error: prog.cpp:15: error: invalid conversion from ‘char’ to ‘const char*’ prog.cpp:15: error: initializing argument 2 of ‘std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::insert(typename _Alloc::rebind<_CharT>::other::size_type, const _CharT*) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]’ Where am I am converting from char to const char* ? Can't I insert a character at position 0 of a string?
Tags (comma-separated)
Save Edits
Cancel