CSC-335 Data Structures and Algorithms
CSC-335 Data Structures and Algorithms
CSC-335 Data Structures and Algorithms
The content of this power point lecture has been originally created by Christos Kolonis and modified by Dr. Ahmad R Hadaegh
1
Chapter Contents
The C++ Standard I/O Classes The C++ String Types
Output is also viewed as a stream of characters Flowing from program to output device
Note Table 5-2 in text for Input Stream Operations and Methods
Note Table 5-3 in text for Output Stream Operations and Methods
Standard ostream objects cout for normal output cerr and clog for error
and diagnostic messages
Examples endl to send a newline showpoint to specify that decimal points be used in
output of reals
Stream activities
Declaring ifstream fileInput; Opening fileInput.open(file_name); Closing fileInput.close();
10
Examples
input, output, append.
11
12
13
Note Table 5-8 in text, String Storage Information Methods Input and output
Use insertion << and extraction >> operators getline () for reading a string and including white spaces
14
15
Also compare() function which returns a negative, 0, or positive value for <, ==, or >
String conversions
When C-style string needed instead of a string object Converts to an array of char
17
Accomplished by transforming
From a string of characters with information To a new string that is the coded message or the ciphertext
The ciphertext may be safely transmitted At a later time the ciphertext is deciphered into plaintext
18
Data Encryption
Simplest encryption schemes use substitution
Each letter replaced by some other letter according to a fixed rule
19
Data Encryption
Improved substitution method is to use a keyword
Specifies several different displacements
Vignre cipher
Keyword added character by character to plane text string Each character represented by position in the string Addition carried out modulo 26
20
Vignre Cipher
Example Character set, positions given by Keyword is DAGGER Plane text IDESOFMARCH thus encrypted
21
Substitution Table
Table of substitutions given
22
Public-Key Encryption
Both sender and receiver must know key
Must be transmitted in some secure manner
24