summaryrefslogtreecommitdiffstats
path: root/sec4.4-dynamic_mem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sec4.4-dynamic_mem.cpp')
-rw-r--r--sec4.4-dynamic_mem.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/sec4.4-dynamic_mem.cpp b/sec4.4-dynamic_mem.cpp
new file mode 100644
index 0000000..9e7b3e4
--- /dev/null
+++ b/sec4.4-dynamic_mem.cpp
@@ -0,0 +1,47 @@
+#include <iostream>
+#include <string>
+#include <vector>
+
+using std::string;
+using std::vector;
+using std::cin;
+using std::cout;
+using std::endl;
+
+static void a_func(void)
+{
+ string name("Kamil Kaminski");
+ name += "\n";
+ cout << name;
+}
+
+static void b_func(void)
+{
+ string dog = "Hera";
+ const char *str = dog.c_str();
+ cout << str << endl;
+}
+
+int main(int argc, char **argv)
+{
+ int *ip = new int[21];
+
+ for (int i = 0; i != 21; ++i)
+ ip[i] = i;
+
+ for (int i = 0; i != 21; ++i)
+ {
+ if (((i+1) % 4 == 0) && i != 0)
+ cout << ip[i] << "\n";
+ else
+ cout << ip[i] << " ";
+ }
+ cout << endl;
+
+ delete [] ip;
+
+ a_func();
+ b_func();
+
+ return 0;
+}