Home >Backend Development >C++ >C++ Function Return Value Quick Facts: Character Type Meanings
#C Function return value quick check: Character type meaning
String type
Type | Meaning |
---|---|
##std::string
| Standard C string type|
std::u16string
| Unicode string type, using 16-bit characters|
std::u32string
| Unicode string type, using 32-bit characters |
char*
| C-style string type, null-terminated |
const char*
| C-style read-only string Type
Character type
Meaning | |
---|---|
Single 8-bit character |
|
Single 8-bit signed character |
|
Single 8-bit unsigned character |
|
Single wide character, size and encoding depend on implementation |
The following function gets the name of a student and returns the name:
std::string get_name() { std::cout << "Enter your name: "; std::string name; std::getline(std::cin, name); return name; }
This function uses the
std::string return type because we need to return a Variable length string.
int main() {
std::string name = get_name();
std::cout << "Hello, " << name << "!" << std::endl;
}
The above is the detailed content of C++ Function Return Value Quick Facts: Character Type Meanings. For more information, please follow other related articles on the PHP Chinese website!