Skip to primary content
Skip to secondary content

C For Dummies Blog

Main menu

  • C For Dummies (home)
  • History
  • Series
  • Supplemental
  • Blog Miscellany

Author Archives: dgookin

Post navigation

← Older posts
Newer posts →

The abs() Function

Posted on November 12, 2016 by dgookin
Reply

Seriously, why do programmers need an abs() function? It’s available in just about every programming language; if you view an alphabetic list of functions, abs() is probably the first one. Yet, what’s the point of a function that simply converts negative values to positive values?
Continue reading →

Posted in Lesson | Leave a reply

When You Need a Function – Solution

Posted on November 8, 2016 by dgookin
Reply

For my solution to this month’s Exercise, I crafted the ask() function. That’s because the original code prompts three times with a question string and an answer buffer, which is the repetitive part of the program I chose to cast into a function.
Continue reading →

Posted in Solution | Leave a reply

Yes, You Can Nest while Loops

Posted on November 5, 2016 by dgookin
Reply

Somewhere in my vast array of teaching material, I claimed that only for loops can be nested. That’s poppycock.
Continue reading →

Posted in Lesson | Leave a reply

When You Need a Function

Posted on November 1, 2016 by dgookin
Reply

I believe two reasons exist for creating functions. The first is repetition; when you have a chunk of code that duplicates several times, it’s best to shove it off into a function where it can be called repeatedly. The second reason is readability.
Continue reading →

Posted in Exercise | Leave a reply

A scanf() String Trick

Posted on October 29, 2016 by dgookin
Reply

I’m not a fan of the scanf() function, despite how handy it can be. It’s a great teaching tool, but for a program that accepts string input, you need to use fgets() instead. Still, scanf() can be used to read a string, providing that you know the whitespace requirements beforehand.
Continue reading →

Posted in Lesson | Leave a reply

Looping Variables End Value

Posted on October 22, 2016 by dgookin
Reply

I received a question on a looping variable and why its value after the loop isn’t the same as the ending value of the loop. It’s a puzzling issue I remember from when I first learned to program, but one that you can understand once you figure out what the loop does.
Continue reading →

Posted in Lesson | Leave a reply

Hunting for a Library

Posted on October 15, 2016 by dgookin
Reply

To add more functionality to the C language, you mix in another library. The library contains routines (functions) that let you control specific hardware, manipulate data, work with graphics, and a host of other capabilities beyond the standard C library.
Continue reading →

Posted in Lesson | Leave a reply

Linking a Library in Code::Blocks

Posted on October 8, 2016 by dgookin
Reply

I’ve not installed Code::Blocks on a Linux computer, but for a moment I’ll pretend that such an installation has the same issue I described in last week’s Lesson: You must manually link in the C language math library to create any program that uses a math.h function.
Continue reading →

Posted in Lesson | Leave a reply

The Curse of Typecasting – Solution

Posted on October 8, 2016 by dgookin
Reply

I hope you didn’t find this month’s Exercise too daunting. In fact, it’s pretty basic stuff, but often something you might forget. In fact, the compiler may remind you when you attempt to pass an argument to a function and it’s of the wrong type.
Continue reading →

Posted in Solution | Leave a reply

Link in the Math Library

Posted on October 1, 2016 by dgookin
Reply

Recently, I had question posed to from a reader from Norway. He was working his way through my book and found that one of the programs wouldn’t compile on his Linux computer. The problem was that the C language math library isn’t automatically linked. The effect is that a linker error appears upon compiling.
Continue reading →

Posted in Lesson | Leave a reply

Post navigation

← Older posts
Newer posts →

Recent Posts

  • Code Page 437
  • Dumping the Screen in W-I-D-E Color
  • Which is Greatest? – Solution
  • Dumping the Screen in Color
  • Which is Greatest?

Recent Comments

  • dgookin on Code Page 437
  • Chris Webb on Code Page 437
  • dgookin on Code Page 437
  • M.Stumpfl on Code Page 437
  • dgookin on Dumping the Screen in W-I-D-E Color

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 1997-2025 by QPBC.
All rights reserved

Proudly powered by WordPress