Mad Man with a Compiler
Showing posts with label
C++
.
Show all posts
Showing posts with label
C++
.
Show all posts
Tuesday, November 2, 2021
Don't Use Modular Arithmetic With Negative Numbers
›
Most programmers are familiar with the "modulus" operator, which is the percent symbol in the language C and many other programmin...
Tuesday, August 15, 2017
A Subtle Difference between C and C++: String Literals
›
For the most part, C++ is a superset of C. You can write C code, rename the file with a .cpp extension, and the compiler will compile it in...
Monday, June 19, 2017
Go To Statement Considered Helpful (part 5: Fun with Switches)
›
For my final segment on the use of gotos, let us not forget one important hidden goto. The switch statement is essentially a goto with a var...
Go To Statement Considered Helpful (part 4: Tail Recursion)
›
One other place where goto can be useful is in implementing tail recursion. As you should recall, tail recursion is when a function returns ...
Go To Statement Considered Helpful (part 3: Finding Matches in a Loop)
›
Another time I often find use for a goto is in a for loop that is scanning an array to find a match. If a match is found, a break terminates...
Go To Statement Considered Helpful (part 2: Nested Loops)
›
If you're in a nested loop in C code, and you want to issue a break or continue statement, but want it to apply to the outer loop, you...
Go To Statement Considered Helpful (part 1: Exceptions)
›
The most obvious use of a goto statement in C is for exception handling. Many people before have noted that this is one good use of gotos. ...
Go To Statement Considered Harmful (revisited)
›
Hopefully you've heard of the famous letter by Edsger Dykstra, "Go To Statement Considered Harmful." This was one of the most...
Thursday, December 10, 2015
Portable Inline Assembly
›
This is a fun little tidbit. Assembly language is, obviously, not portable. If you use inline assembly code in a C program, you won't...
Wednesday, November 25, 2015
Solving a Puzzle
›
Earlier this year, I was given a puzzle as a gift. It's a simple frame with Tetris-like blocks of different shapes, and the object is t...
›
Home
View web version