forked from faranakR/full-cpp-tutorial-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter_42_unicode.cpp
More file actions
63 lines (51 loc) · 1.84 KB
/
chapter_42_unicode.cpp
File metadata and controls
63 lines (51 loc) · 1.84 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*=============================================================================
* CHAPTER 42: UNICODE
* =============================================================================
*
* C++ Development Course - Consolidated Examples
* Original Author: Faranak Rajabi
*
* This file contains 2 code example(s) from Chapter 42.
*
* USAGE:
* - Review each example section
* - Uncomment the code you want to test
* - Compile: g++ -std=c++17 -Wall thisfile.cpp -o program
* - Run: ./program
*
* NOTE:
* Some examples are code snippets designed to illustrate specific
* concepts and may need additional context to compile.
*
=============================================================================*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
// ============================================================================
// EXAMPLE 1: Bad : What does 30 mean ?
// ============================================================================
int main () {
// Bad : What does 30 mean ?
// setMax (30) ;
// if ( name . length () > 30) { }
// Good : Named constant
constexpr int maxNameLength {30};
setMax ( maxNameLength ) ;
if ( name . length () > maxNameLength ) { }
// ============================================================================
// EXAMPLE 2: Octal ( prefix with 0)
// ============================================================================
int main () {
// Octal ( prefix with 0)
int x {012};
std :: cout << x << std :: endl ;
// ============================================================================
// MAIN FUNCTION
// ============================================================================
// Uncomment the examples above and add your test code here
int main() {
std::cout << "Chapter 42: Unicode" << std::endl;
// Your test code here
return 0;
}