use string in c++ code example
Example 1: string in cpp
#include <string>
string greeting = "Hello";
Example 2: declaring strings c++
std::string str = "hello world";
char *str = "hello world";
char str[] = "hello world";
char str[11] = "hello world";
Example 3: c++ string
#include <string>
std::string myString = "Hello, World!";
Example 4: string in cpp
#include <string>
#include <iostream>
int main()
{
string helloWorld = "Hello World!";
std::cout << helloWorld;
string namePerson{};
getline(cin, namePerson);
std::cout << namePerson;
}
Example 5: c++ write string
#include <iostream>
int main() {
std::cout << "Hello" << std::endl;
printf("hello");
}