-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
ex10_05.cpp
35 lines (31 loc) · 1.03 KB
/
ex10_05.cpp
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
//
// ex10_05.cpp
// Exercise 10.5
//
// Created by pezy on 11/9/14.
// Copyright (c) 2014 pezy. All rights reserved.
//
// @Brief In the call to equal on rosters, what would happen if both rosters
// held C-style strings, rather than library strings?
// @Answer It's not quite the same as `std::string`
// Maybe the function 'equal' return true when you make a comparison between
// two c-style strings containers. Nonetheless, we need to keep in mind that
// when it comes to comparison of c-style strings, we need to use 'strcmp' but
// not simply relational operators, for using relational operators is just
// comparison between the address of two c-style strings but not their values.
#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
int main()
{
char c1[10] = "eipi10";
char c2[10] = "eipi10";
std::vector<char*> roster1{c1};
std::list<char*> roster2{c2};
std::cout << std::equal(roster1.cbegin(), roster1.cend(), roster2.cbegin());
return 0;
}
// clang 3.5.0
// out
// 0