[Courses] [C] Beginner's Lesson 4A: Arrays, Qualifiers, and
Reading Numbers
Daniel.
cristofd at hevanet.com
Thu Oct 10 22:06:32 EST 2002
A few little quibbles and clarifications:
>The number of elements in the array is called the DIMENSION
>of the array.
Hm, I don't think so. "float data[5]" is a one-dimensional array, not
a five-dimensional one. I'd call five the "length" of the array.
> Strings are arrays of characters. The special character `\0' (NUL)
> indicates the end of a string.
And is just a zero, by the way. Saying '\0' instead of 0 emphasizes
its function as a string-terminator to the human reader, but makes no
difference to the compiler.
> Note that string and character constants are very different:
> "X" is a one character string. 'Z' is a single character.
That is, "X" is an array with two elements: an 'X' and a '\0', in that order.
> Function Description
> -------------------+--------------------------------------
> strcpy(s1, s2) | Copy s1 into s2.
> strcat(s1, s2) | Concatenate s1 onto end of s2.
Other way around for both these; compare with the examples.
> Since fgets() includes the newline and since there is a NUL
> at the end of the string, if you don't trim off the last
> character, the output would look like this:
>
> The name is Jane
> Doe.
>
Actually, since it'd happen for both names, it should be:
The name is Jane
Doe
.
>Note the ampersand in front of variable1. Don't forget it!
What it means will be explained later, of course.
-Daniel.
--
() ASCII ribbon campaign
/\ against HTML mail
More information about the Courses
mailing list