convert char to string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joah Senegal

    #1

    convert char to string

    Hello I need to convert a chat to a string... but I don't know how to do
    this. i;ve searched the internet but I've only find some code to convert
    char * to string or char [] to string....

    but I just need char to string.

    Anyone knows how to do this ?

    thanks!!!!


  • Victor Bazarov

    #2
    Re: convert char to string

    Joah Senegal wrote:
    Hello I need to convert a chat to a string... but I don't know how to
    do this. i;ve searched the internet but I've only find some code to
    convert char * to string or char [] to string....
    >
    but I just need char to string.
    >
    Anyone knows how to do this ?
    char c('A');
    std::string s(1, c); // s now has "A"

    or

    char c('A');
    std::string s(&c, 1); // s now has "A"

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask


    Comment

    • Jim Langston

      #3
      Re: convert char to string

      "Victor Bazarov" <v.Abazarov@com Acast.netwrote in message
      news:ef8kau$fkk $1@news.datemas .de...
      Joah Senegal wrote:
      >Hello I need to convert a chat to a string... but I don't know how to
      >do this. i;ve searched the internet but I've only find some code to
      >convert char * to string or char [] to string....
      >>
      >but I just need char to string.
      >>
      >Anyone knows how to do this ?
      >
      char c('A');
      std::string s(1, c); // s now has "A"
      >
      or
      >
      char c('A');
      std::string s(&c, 1); // s now has "A"
      >
      V
      Or

      char c('A');
      std::string s;
      s = s + c;

      s now has "A"


      Comment

      Working...