Logo

Programming-Idioms

Create string s containing only the character c.
Implementation
C++

Implementation edit is for fixing errors and enhancing with metadata. Please do not replace the code below with a different implementation.

Instead of changing the code of the snippet, consider creating another C++ implementation.

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
import "fmt"
s := fmt.Sprintf("%c", c)
String s = String.valueOf(c);
String s = Character.toString(c);
String s = c + "";
String s = = new Character(c).toString();
var
  s: string;
begin
  s := 'c';
end.
let s = c.to_string();
s = ?c
import std.conv : to;
string s = to!string(c);
s = [c]
s = c
let s = c
$s = (string) $c;
(defparameter *s* (string c))
character(len=:),allocatable :: s
character(len=1) :: c
s=c
string s = c.ToString();
my $s = $c;
(def s (str c))
s = c
var s = new string(c, 1);
S = [C]
val s: String = c.toString()
var s=c;
S : constant String := "" & C;
to_string(char)
String s = String.format("%s", c);