Chapter7 - Chapter 7 CHARACTER STRING HANDLING We have said...

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

View Full Document Right Arrow Icon
Chapter 7 CHARACTER STRING HANDLING We have said that computers can handle character information as well as perform numerical calculations. But most of the emphasis so far, except for labeling our tables of numerical output, has had very little to do with character string handling. It is true that we have been dealing with words, like identifiers, but these have been in the Fortran programs rather than being handled by them as data. We have, in fact, never had anything but numbers, either real or integer, as data. In this chapter we will learn how to read in character data, how to move it from one place to another in the memory of the computer, and how to search for a particular piece of information. CHARACTER STRINGS The term alphabetic information is sometimes used to describe what we will learn to handle in this chapter. It is true that we will be able to handle what you normally mean by alphabetic information, things like people's names Sarah Marie Wood but we also want to handle things like street addresses. For example, an address like 2156 Cypress Avenue includes digits as well as letters of the alphabet. This kind of information we call alphanumeric or alphameric for short. But that is not all; we want to handle any kind of English text with words, numbers, and punctuation marks, like commas, semicolons, and question marks. This text contains 7 words; doesn't it?
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 | CHAPTER 7 We have defined a word as being a string of one or more characters preceded and followed by a blank or a punctuation mark, other than an apostrophe. This definition makes 7 a word. The information we want to handle is any string of characters that may be letters, digits, punctuations marks, or blanks. We tend to think of a blank as being not a character, but a string of blanks is quite different from a string with no characters at all. We call the special string with no characters at all a null string. We often write b for the blank character so that you can count how many blank characters are in a string. here b is b a b character b string b showing b the b blanks b explicity In Chapter 3 we introduced the characters in the Fortran language. In that listing there are more than we have referred to so far in this chapter. The list of special characters includes symbols we need for arithmetic operations + , - , / , * , as well as the equal sign, comma, and parentheses. One reason we want to be able to handle strings of any of these characters is to be able to work with Fortran programs themselves as data. This is the kind of job a compiler must do, and a programming language similar to Fortran should be suitable for writing a compiler program. This is one of the reasons it has been extended as it was in Fortran 77 to include the ability to handle character strings. CHARACTER STRING VARIABLES
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

Chapter7 - Chapter 7 CHARACTER STRING HANDLING We have said...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online