In game Console fail. string error

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
acerookie1
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 48
Joined: Fri Feb 12, 2010 12:46 pm
Favorite Gaming Platforms: PC, Wii, SNES, GameCube
Programming Language of Choice: C++

In game Console fail. string error

Post by acerookie1 »

when i try to use my addletter function(to compile) i get
  • J:\Documents\DefualtMapEditorBuild\Updated editor\Ace_engineV3\console.cpp||In member function 'void Console::add_letter(char)':|
    J:\Documents\DefualtMapEditorBuild\Updated editor\Ace_engineV3\console.cpp|40|error: invalid conversion from 'char' to 'const char*'|
    J:\Documents\DefualtMapEditorBuild\Updated editor\Ace_engineV3\console.cpp|40|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>]'|
    ||=== Build finished: 2 errors, 0 warnings ===|
buffer is a string>>

Code: Select all

void Console::add_letter(char text)
{
    int length = buffer.length();
    buffer.insert(length,text); // invalid conversion from 'char' to 'const char*'| ,
  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>]'|
}
better error list:
Image
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: In game Console fail. string error

Post by dandymcgee »

Code: Select all

void Console::add_letter(char c)
{
    buffer.insert(buffer.end(), c);
}
From: http://www.cplusplus.com/reference/stri ... ng/insert/
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
acerookie1
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 48
Joined: Fri Feb 12, 2010 12:46 pm
Favorite Gaming Platforms: PC, Wii, SNES, GameCube
Programming Language of Choice: C++

Re: In game Console fail. string error

Post by acerookie1 »

dandymcgee wrote:

Code: Select all

void Console::add_letter(char c)
{
    buffer.insert(buffer.end(), c);
}
From: http://www.cplusplus.com/reference/stri ... ng/insert/

thanx man.
Image
Post Reply