C++: Difference between revisions

248 bytes added ,  30 December 2019
Line 62: Line 62:
===String===
===String===
<code>#include <string></code><br>
<code>#include <string></code><br>
<syntaxhighlight lang="cpp">
// c-str to string
char *old_string = "my c-style string";
string cpp_string(old_string);
// string to c-str
cpp_string.c_str();
// char to string
char my_char = 'a';
string my_str(1, my_char);
</syntaxhighlight>
====String Interpolation====
====String Interpolation====
[https://stackoverflow.com/questions/10410023/string-format-alternative-in-c Reference]
[https://stackoverflow.com/questions/10410023/string-format-alternative-in-c Reference]
Line 79: Line 94:
}
}
</syntaxhighlight>
</syntaxhighlight>
===Filesystem===
===Filesystem===
<code>#include <fstream></code><br>
<code>#include <fstream></code><br>