Presentation is loading. Please wait.

Presentation is loading. Please wait.

TUTORIAL 8 CS 137 F18 November 5th.

Similar presentations


Presentation on theme: "TUTORIAL 8 CS 137 F18 November 5th."— Presentation transcript:

1 TUTORIAL 8 CS 137 F18 November 5th

2 Overview a5 Common Mistakes a6 Progress? a7 Hints String Review
isSubstring.c isValid.c

3 a5 Common Mistakes a5p1: cribbage.c a5p2: poker.c a5p3: event.c
Nobs and same suit Sorting all 5 cards a5p2: poker.c Royal Flush and checking suits Ordering of Rules a5p3: event.c Very Well Done No need to sort

4 a6 Progress? Questions? a6p1: euclidean_algorithm.c a6p2: run.c
Think about private cases a6p2: run.c Dealing with more than 2 digits a6p3: merge.c Sort immediately

5 a7 Hints Questions? MUST remove main function (comment or delete)
Strings are constant (string literal); do not mutate s; use heap Test for empty string and NULL as requested a7p1: reverse.c simple; do not overthink a7p2: num_duplicates.c Utilize given macro a7p3: largest_square.c Understand what is asked Use strncmp

6 string.h Contains: size_t type NULL macro string functions (strlen, strcmp, strcat) memory functions (memset, memcpy, memcmp) Always care with NULL pointer! strlen see string.c

7 isSubstring.c a string t is a substring of string s if and only if string t is completely contained within string s all characters in t appear in order and adjacent to one another in s create the function isSubstring that returns whether a given string t is a substring of a given string s Assume that s and t are non-empty and non-null bool isSubstring(const char *s, const char *t);

8 isValid.c Create a C function bool isValid(char *username, char *pword) that takes in a username (max length 8) and a possible password as strings and returns whether that password is valid. If invalid, print out all the messages saying why it was invalid. Assume username is valid Assume password contains standard keyboard input A valid password must: be length at least 8 characters not contain the same character twice in a row contain a lower and upper case letter contain a number and a special character not contain any whitespace characters not contain the username as a substring

9


Download ppt "TUTORIAL 8 CS 137 F18 November 5th."

Similar presentations


Ads by Google