A few years back I found myself hooked on a website that presented a number of password cracking challenges. You had to complete the first challenge before you could get to the second and so on. It started with a password listed in plain HTML source code and moved on to executables and logging into [...]
What’s a Core Dump? It’s a file created when your program terminates abnormally. It contains a snapshot of the program’s state at the time of the failure. What does it look like? On Linux it will appear in the same location as the executable and will be named something like: core.4196 Where the number is [...]
I wrote some posts a while back on the principles of object oriented programming and have collated them into this 10 minute guide as a PDF file that you can download. It covers the main concepts of OOP and also has a simple example of polymorphism in C++. Get your copy here.
There you are, happily programming away, when suddenly you get a compile error: error: jump to case label error: crosses initialization of ‘int x’ “Huh?” You say, peering at the computer screen. Your code looks fine, so what does it mean? Look closely at your switch statement. A switch statement contains case labels, which provide [...]
Lots of functions in the C standard library will set errno to an error code if something goes wrong, so using errno in your programming can help you pinpoint where problems are occurring and what they might be. errno remains set at the last error code, so bear in mind that: a) if two subsequent [...]
Occasionally I’ve heard these terms used interchangeably – but they actually refer to two completely separate concepts. So what’s what? Overloading describes the creation of a method with the same name as an existing method, but different parameters. For example: int method(); int method(int); int method(int, double); Overriding describes the creation of a method in [...]
I can’t leave the subject of GDB alone for too long, so today I thought I’d talk about GDB init files. Each time GDB is run, it checks the local directory for the existence of a file called .gdbinit. If it finds this file, it reads the contents and runs any commands it finds there. [...]
28 September 2011 – 08:35
When you first start using C++ you tend to set member variables with default values inside your constructor. For example, you might have a class called Message that has three variables, and your constructor sets the default values like this: Message::Message() { messageLength = 0; messageType = 0; messageBody = “Empty message”; } This is [...]
21 September 2011 – 12:51
Let’s take a look at bit shifting in practice. Say we have a variable called colour, that contains an RGBA value. If you have never had any experience with graphics, all you need to know is that the colours you see on your screen may be represented as a combination of four different variables – [...]
14 September 2011 – 12:29
The left and right shift operators are the last two bitwise operators for us to look at. In C (and C++), << and >> are used to shift bits around inside bytes. Not just in any random fashion – these operators move all the bits either to the left or to the right, exactly as [...]