MAT 21B Lecture Notes - Lecture 17: Newline, Substring, Null Character

22 views2 pages
School
Department
Course
Professor
Lecture 17
String assignment and copy
- Assigning an existing string to a pointer makes the pointer point at the sae string
- Strcopy() can be a copy a sting into another string
- Refer to ppt for line of code
Sting copy and substring
- Strcpy() takes a destination, a cource and maximum number of characters to copy
o Useful for substrings
o And preventing overflow
o Character ‘/tetha’ is equivalent to the numerical value of tetha
o An array reference with no subscript represent the address of the first element
Course +3 to get to the address of the character at located three positions
away from the beginning
Equivalent to &couse[3]
String concatenation
o Strcat() to append a string to an already existing string
Potential risk of overflow
o Strncat() to specify the maximum number of characters
String input
o Fgets() properties
Will never read more than max
Will always end the resulting sting with a null character
Can read from various input streams
Does not skip leading whitespace characters
Stops on the first newline or when reaching the maximum size
Includes the newline as part of the string
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in
beigecamel74 and 41 others unlocked
MAT 21B Full Course Notes
83
MAT 21B Full Course Notes
Verified Note
83 documents

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents