Thursday, September 11, 2014

Errata for: Sams Teach Yourself C Programming in One Hour a Day, Seventh Edition

     I'm currently reading Sams Teach Yourself C Programming.  Although not new to C, I like to relearn and read works on C programming.  In this post I thought it would be good to keep my own errata page on this book as it seems the website for tracking errata from the publisher is not yet updated.

     Check back often as I go through the book I will update the errata here.  If you have any errata yourself, please let me know and I will add it.
Thanks.

pg. 15 Step 8:
Although not errata per se, it is rather Windows centric.
If you are on OSX you will not see hello.obj or hello.exe but rather a.out
(or if you used gcc hello.c -o hello hello.c you will see hello.out).
To run hello.out (or a.out) type ./hello.out (or ./a.out) depending.
(I can't speak for Linux OS).

pg. 35 Exercise 5:
line 9 shows  fgets(buffer);  Your compiler should complain it needs 3 arguments.
line 9 should be  fgets ( buffer , 256 stdin );

pg. 44 Table 3.3:
"Full Name" and "Commonly Used Keyword" labels are switched.

pg 60 Do/Don't list:  Under Don't - second Don't 'forward slash' should be 'backslash'.
  Don't forget to use a backslash to continue a string of characters onto a second line.

pg 89 Exercise 3: Says to make listing 4.1 count up instead of down, but listing 4.1 already does that.

pg 112 Last Sentence under Recursion: "the factorial of 9 and larger values are outside the allowed
  range of integers."  This depends on your compiler.  Xcode for mac for instance
  lists an unsigned integer to be 4 bytes and can handle a factorial up to 12! .

pg 238 Question 10b.  answer is shown as 'A' but 10e. is shown as 73.  If by values they mean
  the integer then 10b. (*string) then should be 65 not 'A' or if by value they mean char, then
  10e should be ' I '.  Inconsistent.

pg 242 Defining and Declaring.  This author mixes and mostly inverts the definition of 'declaration'
  and 'definition' of the type struct.  As per 'The C Programming Language' by K&R, "The keyword
  struct introduces a structure declaration, which is a list of declarations enclosed in braces." Not until
  a struct is instantiated is the struct 'defined'.  When it is defined, then storage is created and set aside.

pg 257 Line 4 of program.  Should have a semi-colon after bracket.  };

pg 266 Line 17 of program should be:        17:    {4, "Benjamin"},

pg 366 Listing 15.2  %p's should be %lu's.    so:
    printf("\nThe size of multi = %p", sizeof(multi));     //should be:
    printf("\nThe size of multi = %lu", sizeof(multi));    //same for next two lines.

pg 367 5th paragraph: Says "In other words, it's incremented by the size of the object to which it
    points."  While not an error, it is an ambiguous idea with the previous page that shows 'multi' to be     of size 32.  So one would think multi + 1 should be pointing to something 32 bytes larger; but it
    does not. It points to something 16 bytes larger.

pg 367 Listing 15.3 (all printf's) uses format specifier %u and it should be %p for addresses.
    also, 'value' should be 'address' in lines 10 and 11.





Saturday, September 22, 2012

I Can't Find My Cursor

I'm not stupid.  I've done some programming.  I'm an electronics technician for over 30 years.
But now that I have my 27" iMac and will soon be adding another monitor, the real estate that one can lose their cursor on is growing.

After a quick search I found five options:

1) Hold Ctrl+Scroll and the screen will zoom into where the mouse is.

2) Move all the way up to the left and click, and the menu will expand showing you where the mouse is.

3) OmniDazzle from omnigroup.com

4) mouseposefrom from Boinx Software

and

5) MouseLocator from 2pointfish software company.

I chose 5.  MouseLocator from 2pointfish.
It's easy, download, install (I then keep the .dmg in a folder called 'downloaded software', because it has the uninstaller), then when you lose your mouse, just hit Ctrl + Space (can be changed to anything you want).

This is what I see for the 2 secs that it is set up for:



Works great.  No more getting lost in a sea of pixels.

Saturday, July 7, 2012

Microstick II Start Up

I got the Microchip Microstick II and found some things that others may learn from as well.

I started using the Pic32MX250F128b (Microchip left the 'b' off in the parts included list, but the 'b'
version Pic32 is the 28 pin one that comes with the Microchip II).

First, using Microchip MPLAB X IDE the Microstick II was not recognized by the MPLAB (inactive connection).
I had to restart MPLAB X, and replug in the Microstick II into the USB cable.
Using OSX, the directions state a)... b) ... select Starter Kits (PKOB), and then click Apply.
I had to click on the Serial number, then 'Apply' to get it to work.

Second, the code example given must be for MPLAB 8.x as MPLAB X did not recognize that file.
So, just start a new project like it states in the MPLAB X Quick Start guide, then right click on Source Files in the tree and import the BlinkLED.c file from the MPLAB 8.x example files.
Then 'c)' should be: c) Select 'Debug Project' to download and run the project.
Not Run>Run Project.  (that must be in 8.x version).

MPLAB X will alert you that you it must disable the watchdog timer to make the program work correctly for this session, hit yes or okay and then your LED will do it's blinking thing.



Wednesday, June 6, 2012

Creating An Ellipsoid in a 3D Grapher

When creating an Ellipsoid in a 3D Grapher, whether it be online or Apple's Grapher that comes with Mac, or using a formula inside of a 3D graphics program such as Blenders Add Mesh Math Addon, use this formula.
X function is:   a(cos(u))*cos(v)
Y function is:   b(cos(u))*sin(v)
Z function is:   c(sin(u))

U min: -Pi/2
U max: Pi/2
V min: -Pi
V max: Pi
a = Some number or function greater than 0
same for b and c function, or some constant n.


  • a>b>c — tri-axial or (rarely) scalene ellipsoid;
  • a=b>c — oblate ellipsoid of revolution (oblate spheroid);
  • a=b<c — prolate ellipsoid of revolution (prolate spheroid);
  • a=b=c — the degenerate case of a sphere;

In Apple Grapher I used this:


The 3,2,2 after the [x,y,z] is where you would put the a,b,c if you like.

This took me all day to figure out.  You got it in 2 secs.  Use carefully with beer.

Thursday, November 3, 2011

Learning C - C Primer Plus

I thought I would post some chapter review programs from chapters I'm reading in C Primer by Stephen Prata. This won't mean anything to anyone unless they know C programming. I'm basically putting it here so others can learn from what I've done and partly because I think a computer program is beautiful. Sort of in an artistic way. The characters and code seem like a picture to me.

This C program converts Centimeters to Feet and Inches:

//*************************************************
#include <stdio.h>
#define CMPERFT 30.48

float cm,ft,in;

int main (void) {
printf("Enter a height in centimeters (<=0 to quite): ");
scanf("%f", &cm );

while (cm > 0) {
ft = cm/CMPERFT;
in = (ft - (int)ft) * 12; //You can't find a remainder of a float with modulus.So use Cast
printf("\n%0.2f cm = %d feet, %0.3f inches\n", cm, (int)ft ,in);
printf("Enter a height in centimeters (<=0 to quite): ");
scanf("%f", &cm );
}

return 0;
}


//************************************************

Thursday, October 27, 2011

Finally Cut Comcast Cable

Well, I finally got fed up with Comcast Cable TV's high prices and cut the cable.
Though they'll never know. I told them I was moving so I wouldn't incur any additional fees.
Soon I'll be placing an Antenna in the attic for those times when I want the TV to make some noise. But other than that, I'll get what I want off of the internet. I've had cable since 1985 when I got my fist apartment. They've made a fortune off of me if you think the average over those 26 years has been about $40 a month, that comes to about $12,480. That's a lot for TV that is paid for by commercials anyway.
So long Comcast, you suck.... have been sucking for 26 years....money out of my wallet.
No more, good riddens.


Saturday, August 13, 2011

invalid literal for int() with base 10:

So I'm learning Python programming in my spare time.
For two hours I was stuck on this simple error:
invalid literal for int() with base 10:

Turns out, if you input a string number like "4.0" and you want the integer of it,
you must first make the string a float, and then make the float an integer.
"4.0" > float("4.0") > int(4.0) is the path.

So
>>>int("4.0") #this will give you an error
>>>int(float("4.0")) #this will work and give you >>>4

The reason I think this is necessary is because Python wants you to verify that you
know you are converting a float to an integer. It doesn't want to assume you know that.