Last active
September 17, 2020 18:10
-
-
Save Adobe-Android/39b11cac418e03a521aeea862ac6e69e to your computer and use it in GitHub Desktop.
A small modern C++ example converting a std::string to a c-style string (character array).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
void print_to_screen(const char* char_array) { std::cout << char_array << '\n'; } | |
int main() { | |
std::string std_str{"Hello, World!\n"}; | |
const char* char_array{std_str.c_str()}; | |
print_to_screen(char_array); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment