INTRODUCTION TO PROGRAM DESIGN
Lecture 13: Bits, Characters,
C Strings and structs
Yun-Shan Hsieh (謝昀珊),
Department of Computer Science and Information Engineering, NCKU
Acknowledgement: Slides template by https://slidesgo.com
Structure Definitions
struct Card { Card oneCard; struct Card {
string face; Card deck[52]; string face;
string suit; Card* cardPtr; string suit;
}; } oneCard, deck[52], * cardPtr;
struct Example {
char c;
int i;
} sample1, sample2;
2
Example: Card Shuffling and Dealing
Simulation
3
Example: Card Shuffling and Dealing
Simulation (Cont.)
4
Example: Card Shuffling and Dealing
Simulation (Cont.)
5
Example: Card Shuffling and Dealing
Simulation (Cont.)
6
Example: Card Shuffling and Dealing
Simulation (Cont.)
7
Example: Card Shuffling and Dealing
Simulation (Cont.)
8
Example: Card Shuffling and Dealing
Simulation (Cont.)
9
Bitwise Operators
10
Printing a Binary Representation of an
Integral Value
11
Printing a Binary Representation of an
Integral Value (Cont.)
12
Printing a Binary Representation of an
Integral Value (Cont.)
13
Printing a Binary Representation of an
Integral Value (Cont.)
14
Bitwise AND, Inclusive OR, Exclusive OR
And Complement Operators
15
Bitwise AND, Inclusive OR, Exclusive OR
And Complement Operators (Cont.)
16
Bitwise AND, Inclusive OR, Exclusive OR
And Complement Operators (Cont.)
17
Bitwise AND, Inclusive OR, Exclusive OR
And Complement Operators (Cont.)
18
Bitwise AND, Inclusive OR, Exclusive OR
And Complement Operators (Cont.)
19
Bitwise Shift Operator
20
Bitwise Shift Operator (Cont.)
21
Bitwise Shift Operator (Cont.)
22
Bitwise Assignment Operators
23
Operator Precedence
24
Operator Precedence (Cont.)
25
Bit Fields
26
Bit Fields (Cont.)
27
Bit Fields (Cont.)
28
Bit Fields (Cont.)
29
Bit Fields (Cont.)
30
Bit Fields (Cont.)
31
Bit Fields (Cont.)
32
Character-Handling Library
33
Character-Handling Library (Cont.)
34
Character-Handling Library (Cont.)
35
Character-Handling Library (Cont.)
36
Character-Handling Library (Cont.)
37
Character-Handling Library (Cont.)
38
Character-Handling Library (Cont.)
39
Character-Handling Library (Cont.)
40
Character-Handling Library (Cont.)
41
Character-Handling Library (Cont.)
42
Character-Handling Library (Cont.)
43
Character-Handling Library (Cont.)
44
Character-Handling Library (Cont.)
45
C String-Manipulation Functions
46
C String-Manipulation Functions (Cont.)
47
C String-Manipulation Functions (Cont.)
48
C String-Manipulation Functions (Cont.)
49
C String-Manipulation Functions (Cont.)
50
C String-Manipulation Functions (Cont.)
51
C String-Manipulation Functions (Cont.)
52
C String-Manipulation Functions (Cont.)
53
C String-Manipulation Functions (Cont.)
54
C String-Manipulation Functions (Cont.)
55
C String-Manipulation Functions (Cont.)
56
C String-Manipulation Functions (Cont.)
57
C String-Manipulation Functions (Cont.)
58
C String-Manipulation Functions (Cont.)
59
C String-Conversion Functions
60
C String-Conversion Functions (Cont.)
61
C String-Conversion Functions (Cont.)
62
C String-Conversion Functions (Cont.)
63
C String-Conversion Functions (Cont.)
64
C String-Conversion Functions (Cont.)
65
C String-Conversion Functions (Cont.)
66
C String-Conversion Functions (Cont.)
67
Search Functions of the C String-Handling
Library
68
Search Functions of the C String-Handling
Library (Cont.)
69
Search Functions of the C String-Handling
Library (Cont.)
70
Search Functions of the C String-Handling
Library (Cont.)
71
Search Functions of the C String-Handling
Library (Cont.)
72
Search Functions of the C String-Handling
Library (Cont.)
73
Search Functions of the C String-Handling
Library (Cont.)
74
Search Functions of the C String-Handling
Library (Cont.)
75
Search Functions of the C String-Handling
Library (Cont.)
76
Memory Functions of the C String-Handling
Library
77
Memory Functions of the C String-Handling
Library (Cont.)
78
Memory Functions of the C String-Handling
Library (Cont.)
79
Memory Functions of the C String-Handling
Library (Cont.)
80
Memory Functions of the C String-Handling
Library (Cont.)
81
Memory Functions of the C String-Handling
Library (Cont.)
82
Memory Functions of the C String-Handling
Library (Cont.)
83
Memory Functions of the C String-Handling
Library (Cont.)
84
References
• https://en.cppreference.com/w/cpp/header/cmath
• https://en.cppreference.com/w/cpp/chrono/c/time
85
Thank You Very Much!
Questions & Answers?
86