150
|
1 #include <iostream>
|
|
2 #include <string>
|
|
3 #include <cstring>
|
|
4
|
|
5 struct Five
|
|
6 {
|
|
7 int number;
|
|
8 const char *name;
|
|
9 };
|
|
10
|
|
11 Five
|
|
12 returnsFive()
|
|
13 {
|
|
14 Five my_five = {5, "five"};
|
|
15 return my_five;
|
|
16 }
|
|
17
|
|
18 unsigned int
|
|
19 fib(unsigned int n)
|
|
20 {
|
|
21 if (n < 2)
|
|
22 return n;
|
|
23 else
|
|
24 return fib(n - 1) + fib(n - 2);
|
|
25 }
|
|
26
|
|
27 int
|
|
28 add(int a, int b)
|
|
29 {
|
|
30 return a + b;
|
|
31 }
|
|
32
|
|
33 bool
|
|
34 stringCompare(const char *str)
|
|
35 {
|
|
36 if (strcmp( str, "Hello world" ) == 0)
|
|
37 return true;
|
|
38 else
|
|
39 return false;
|
|
40 }
|
|
41
|
|
42 int main (int argc, char const *argv[])
|
|
43 {
|
|
44 std::string str = "Hello world";
|
|
45 std::cout << str << std::endl;
|
|
46 std::cout << str.c_str() << std::endl;
|
|
47 Five main_five = returnsFive();
|
|
48 #if 0
|
|
49 print str
|
|
50 print str.c_str()
|
|
51 #endif
|
|
52 return 0; // Please test these expressions while stopped at this line:
|
|
53 }
|