TUTORIAL 8 CS 137 F18 November 5th.

Slides:



Advertisements
Similar presentations
CS 116 Tutorial 6 Strings, Raw Input, Lists. 1. Write a function convert_format that consumes nothing, but takes keyboard input. The program prompts "Enter.
Advertisements

LECTURE 17 C++ Strings 18. 2Strings Creating String Objects 18 C-string C++ - string \0 Array of chars that is null terminated (‘\0’). Object.
Introduction to Programming Lecture 39. Copy Constructor.
 2003 Prentice Hall, Inc. All rights reserved Fundamentals of Characters and Strings Character constant –Integer value represented as character.
Strings.
1 Chapter 10 Strings and Pointers. 2 Introduction  String Constant  Example: printf(“Hello”); “Hello” : a string constant oA string constant is a series.
Lecture 09 Strings, IDEs. METU Dept. of Computer Eng. Summer 2002 Ceng230 - Section 01 Introduction To C Programming by Ahmet Sacan Mon July 29, 2002.
Ch 8. Characters and Strings Timothy Budd 2 Characters and Literals Strings Char in C++ is normally an 8-bit quantity, whereas in Java it is a 16-bit.
Lecture 9. Lecture 9: Outline Strings [Kochan, chap. 10] –Character Arrays/ Character Strings –Initializing Character Strings. The null string. –Escape.
Lecture 20 Arrays and Strings
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
 2000 Prentice Hall, Inc. All rights reserved Fundamentals of Strings and Characters String declarations –Declare as a character array or a variable.
ECE Application Programming Instructor: Dr. Michael Geiger Spring 2012 Lecture 31: PE5.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Characters and Strings.
Current Assignments Homework 5 will be available tomorrow and is due on Sunday. Arrays and Pointers Project 2 due tonight by midnight. Exam 2 on Monday.
1 CSE1303 Part A Data Structures and Algorithms Semester 2, 2006 Lecture A1 – Welcome & Revision.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 8 - Characters and Strings Outline 8.1Introduction 8.2Fundamentals of Strings and Characters 8.3Character.
Chapter 8 Characters and Strings Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Fundamentals of Strings and Characters Characters.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 8 - Characters and Strings Outline 8.1Introduction.
Friday, January 05, 2007 A few weeks of developing and testing can save a whole afternoon in the library. -Anonymous.
String What it is Why it’s useful library routines for handling strings how to input a string from the keyboard.
 2007 Pearson Education, Inc. All rights reserved C Characters and Strings.
1)Never start coding unless you understand the task! 2)Gather requirements first. This means identify the problem and ask questions about it. Now you kind.
Strings in C. Strings are Character Arrays Strings in C are simply arrays of characters. – Example:char s [10]; This is a ten (10) element array that.
 2007 Pearson Education, Inc. All rights reserved C Characters and Strings.
Working with Strings Lecture 2 Hartmut Kaiser
 2000 Prentice Hall, Inc. All rights reserved. Chapter 8 - Characters and Strings Outline 8.1Introduction 8.2Fundamentals of Strings and Characters 8.3Character.
Dynamic memory allocation and Pointers Lecture 4.
Arrays II (Strings). Data types in C Integer : int i; Double: double x; Float: float y; Character: char ch; char cha[10], chb[]={‘h’,’e’,’l’,’l’,’o’};
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI C-Style Strings Strings and String Functions Dale Roberts, Lecturer.
13. Strings. String Literals String literals are enclosed in double quotes: "Put a disk in drive A, then press any key to continue\n“ A string literal.
 2003 Prentice Hall, Inc. All rights reserved. 5.11Function Pointers Pointers to functions –Contain address of function –Similar to how array name is.
 2003 Prentice Hall, Inc. All rights reserved. 11 Fundamentals of Characters and Strings Character constant –Integer value of a character –Single quotes.
Chapter 8 Characters and Strings. Objectives In this chapter, you will learn: –To be able to use the functions of the character handling library ( ctype).
C++ Programming Lecture 19 Strings The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Characters and Strings Functions.
DCT1063 Programming 2 CHAPTER 3 STRINGS Mohd Nazri Bin Ibrahim Faculty of Computer, Media & Technology TATi University College
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Characters and Strings Dale Roberts, Lecturer Computer Science,
Strings. String Literals String literals are enclosed in double quotes: "Put a disk in drive A, then press any key to continue\n“ A string literal may.
EC-111 Algorithms & Computing Lecture #10 Instructor: Jahan Zeb Department of Computer Engineering (DCE) College of E&ME NUST.
Pointers and Dynamic Arrays
C Characters and Strings
Strings CSCI 112: Programming in C.
Course Contents KIIT UNIVERSITY Sr # Major and Detailed Coverage Area
INC 161 , CPE 100 Computer Programming
Pointers & Arrays 1-d arrays & pointers 2-d arrays & pointers.
C Characters and Strings
Fundamentals of Characters and Strings
Working with Strings Lecture 2 Hartmut Kaiser
Chapter 8 - Characters and Strings
CSCI206 - Computer Organization & Programming
INC 161 , CPE 100 Computer Programming
Pointers, Dynamic Data, and Reference Types
Working with Strings Lecture 2 Hartmut Kaiser
Programming with ANSI C ++
Class Examples.
String What it is Why it’s useful
How to use Strings (way to quick briefing)
EECE.2160 ECE Application Programming
CPS120: Introduction to Computer Science
TUTORIAL 9 CS 137 F18 November 13th.
TUTORIAL 11 CS 137 F18 November 27th.
TUTORIAL 7 CS 137 F18 October 30th.
CS250 Introduction to Computer Science II
C++ Programming Lecture 20 Strings
Lecture 2 Arrays & Pointers September 7, 2004
Characters and Strings Functions
CS31 Discussion 1H Fall18: week 6
C Characters and Strings
Presentation transcript:

TUTORIAL 8 CS 137 F18 November 5th

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

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

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

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

string.h https://www.tutorialspoint.com/c_standard_library/string_h.htm 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

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);

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