summaryrefslogtreecommitdiff
path: root/CPP/cpp_book/chap1/1_2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/cpp_book/chap1/1_2.cpp')
-rw-r--r--CPP/cpp_book/chap1/1_2.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/CPP/cpp_book/chap1/1_2.cpp b/CPP/cpp_book/chap1/1_2.cpp
new file mode 100644
index 0000000..b914271
--- /dev/null
+++ b/CPP/cpp_book/chap1/1_2.cpp
@@ -0,0 +1,26 @@
+#include <iostream>
+#include <string>
+
+int
+main()
+{
+ std::cout << "Enter your first name: ";
+ std::string name;
+ std::cin >> name;
+
+ const std::string greeting = "Hello, " + name + "!";
+
+ const std::string spaces(greeting.size(), ' ');
+ const std::string second = "* " + spaces + " *";
+ const std::string first(second.size(), '*');
+
+ std::cout << msg << std::endl;
+
+ std::cout << std::endl; // Flush stdou buffer
+
+ std::cout << first << std::endl;
+ std::cout << second << std::endl;
+ std::cout <<"* " + greeting + " *" << std::endl;
+ std::cout << second << std::endl;
+ std::cout << first << std::endl;
+}