[Courses] [C] Beginner's Lesson 4A: Arrays, Qualifiers, and Reading Numbers

Peter Clay pete at flatline.org.uk
Fri Oct 11 01:06:36 EST 2002


On Thu, 10 Oct 2002, Morgon Kanter wrote:

> First of all, could you please, in the next part of the lesson, include a 
> list of what each of the functions in the standard C library does? I want 
> to print something like this out to have on hand, but you only list a 
> couple each lesson! =)

Er, there's quite a lot of them .. I'd reccomend you get a copy of
Kernighan and Ritchie, as it's the best C reference money can
buy. Appendix B briefly describes all the standard library functions.
The rest of the book provides terse but 100% accurate explanations of the
rest of the language.

> The first thing I had to say:
> Hey, I tried this out without the .0s at the end of the numbers and it 
> worked exactly the same. Why are you including .0s for the floats? I know 
> you have to do this in Java, but not here it seems. What I'm talking about 
> is when you wrote:

It works just as well because C inserts an conversion for you. It's good
practice to add the .0 to remind the reader you're doing floating point,
and to prevent mistakes like:

float f = 2/3;

(Can you see why that doesn't assign two-thirds to f?)

> good idea to add that I guess. Too bad you can only concatenate one thing 
> at a time. This is where a concatenation operator would have been nice =)

C++ gives you string concatenation operators, along with a boatload of
other handy gizmos.

Pete
-- 
Peter Clay                                         | Campaign for   _  _| .__
                                                   | Digital       /  / | |
                                                   | Rights!       \_ \_| |
                                                   | http://uk.eurorights.org





More information about the Courses mailing list