DOC PREVIEW
TRINITY CSCI 1320 - Strings

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1Strings10/24/20072Opening Discussion■Let's look at solutions to the interclass problem.■Denim Group presentation in HAS 340 at 5pm.■Answers to the minute essay&a – int**b – int*(b+2) – int&(*b) – int**(&a) – int■Do you have any questions about the assignment?3Strings■I'm deviating from the order of the book for this because I want us to be able to use strings. We'll go into more detail later.■A string in C is a null terminated array of characters. That is to say it is an array of characters with the value zero stored after the last character.■Note this is the value zero, not the character zero. Since zero is not a valid character in ASCII this can be used to end the string.4Initializing String Variables■When you declare an array of chars you can set it equal to a string literal.■You don't have to provide the length of the array unless you want extra space in the string.5Strings as Pointers■Many functions will treat strings as a char* or a const char* instead of a char[]. As we'll see later, this makes sense because arrays and pointers are extremely similar in many ways.■When you write a function that deals with a string you can have it take either a char* or a char[]. I will probably use char* out of habit.6Writing some String Functions■Let's write one or two functions that deal with strings.7String Library■Obviously, many people need these functions. As you would expect, they exist in a library for exactly this reason.■You can include string.h and look in the man pages to see all the different things that the C libraries allow you to do with strings.■While it is good to know how to manipulate strings, you will probably use the libraries for most basic manipulations.8String I/O■In printf and scanf you use %s to signify a string.■For scanf it only reads one word and you don't need to put the & in front of the variable because an array is like a pointer.■The fgets function can be used to read in a full line.9Minute Essay■Write a function that takes a string as input and returns the number of lower case letters in the string.■Denim Group presentation in HAS 340 at 5pm.■Interclass Problem – Play with strings some and write a program that has the user input a string, then does some manipulations and prints out an altered string. You can pick the


View Full Document

TRINITY CSCI 1320 - Strings

Documents in this Course
Functions

Functions

10 pages

Functions

Functions

10 pages

Graphics

Graphics

10 pages

Graphics

Graphics

11 pages

Loops

Loops

4 pages

Loops

Loops

3 pages

Functions

Functions

10 pages

Loops

Loops

11 pages

Graphics

Graphics

11 pages

Graphics

Graphics

12 pages

Sorting

Sorting

11 pages

Sorting

Sorting

10 pages

Arrays

Arrays

10 pages

Loops

Loops

18 pages

Load more
Download Strings
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Strings and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Strings 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?