6、字符串型.cpp 376 B

123456789101112131415161718
  1. #include <iostream>
  2. int main6()
  3. {
  4. //1、C风格字符串
  5. //注意事项:1、 char字符串名后加 [] 2、 = 后面要用双引号包含起字符串
  6. char str1[] = "Hello World";
  7. std::cout << str1 << std::endl;
  8. //2、C++风格字符串
  9. //注意事项:包含一个头文件 #include <string>
  10. std::string str2 = "Hello World";
  11. std::cout << str2 << std::endl;
  12. system("pause");
  13. return 0;
  14. }