summaryrefslogtreecommitdiffstats
path: root/sec4.4-dynamic_mem.cpp
blob: 9e7b3e45206b7f65a239ec3136dd760b2f98572e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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;
}