{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

C By Discovery (4th Edition)

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Intermediate Programming CSE 1320 Lecture 11 Chapter 5: 5.4-5.6 Length of a string Make a copy of a string Compare two strings Concatenate one string to the end of another Common String Library Calculate the length of a string – Number of characters in the string before the first null character Parameter: Pointer to first character Return: size_t (sizes or lengths in bytes compatible with integer types) length = strlen(“CSE1320”); length = strlen(stringptr); strlen() Makes a copy of a string • Parameters Address of the array where the copy will be located (char *) Address of the first character in the string to be copied strcpy(copy, original); strcpy(copy, “CSE1320”); copy must be the address of an array allocated by the program Returns first parameter strcpy() Appends one string to the end of another • Parameters – Address of an array containing a null- terminated string – (char *) Pointer to a null-terminated string There must be adequate unused space in
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}