Monday, 6 November 2017

CorelCAD 2017 review

CorelCAD 2017 £759.99

For 3D CAD, CorelCAD seems to provide a lot of power at a moderate price. But does it live up to its promise? Dermot Hogan gives his opinion…

One thing that you learn quite quickly about lathes, milling machines and the like is that, unlike a PC, there isn’t a delete key. If you make a mistake, you start again. Which is why it is pretty much essential to have a CAD package to produce a design – a plan – from which to work. Yes, you can use graph paper and a pencil to produce a design. You can also use a quill and ink if you like …

I’ve been using CorelDraw for a number of years as a (very) lightweight CAD package for simple mechanical drawings. It works quite well for that, in that you can add dimensions, use layers and colour items to get an idea of what you want to produce. But a 2D package that is aimed mainly at artists and illustrators doesn’t really cut it when you want to produce something like a simple right-angled mounting plate - let alone a robotic tracked vehicle. Nor, to be fair, is CorelDraw intended for that purpose.

So I started looking for something a bit more 3D-oriented which would fit in with what I had used and knew in CorelDraw.  CorelCAD seemed the obvious place to start.

CorelCAD is essentially a re-packaged version of Graebert’s Ares Commander CAD system. It’s aimed squarely at AutoCAD-style users and as far as I can see does a pretty good job of it too. I’m no AutoCAD expert and, to be honest, the thought of using a command-line input to perform operations and using LISP as a programming language seem a bit, well, 1990s. But who am I to say? AutoCAD is doing very nicely thank you, and there are many happy users out there.

This is a simple plate with a hole and a cylinder in the default wireframe view. Note the rather nice ‘ribbon’ menu which is an option over the older ‘classic’ menus.

Design in 2D

CorelCAD works in AutoCAD’s native DWG format and you can import and work with AutoCAD drawings directly. That’s a big plus – there are many manufacturers who produce CAD drawing in DWG format for download and incorporation into your designs. But you can also import and export to CorelDraw’s native CDR format. For me, the export worked ok, but I had difficulty with importing my existing mechanical designs. CorelCAD did import them – but the dimensions were not correct (they were page dimensions, not the dimensions I had specified in CorelDraw) and in some cases the relative sizes were not correct. I was hoping that I could import my existing CorelDraw diagrams and start working on them immediately. In the end I decided that it would be simpler to start again.

With any CAD package there is going to be a learning curve. By all accounts CorelCAD is simpler to learn than AutoCAD but, even so, it’s a complicated and powerful design package and I found that it took me some time to get into producing even simple 3D objects. One of the rather strange things about CorelCAD is the help system. It really is the good old fashioned Windows XP style help. It’s comprehensive, true – but compared to the help provided with AutoCAD Fusion 360 or SolidWorks (with good short video tutorials and well laid out HTML pages on the web) it looks pretty antiquated.

2D drawings are easy, though. Even though the menus are different, I found that I could re-use much of what I knew from CorelDraw to lay out and align rectangles, etc. and specify the distance between various components – the dimensioning tools are first rate. I found the ‘Quick Input’ mechanism, where you can specify the dimensions of, say, a rectangle, on the fly to be particularly useful. As you might expect, the ability to accurately produce 2D layouts and plans is in a different ballpark to CorelDraw, and having using CorelCAD for drafting and creating 2D designs, I’d be reluctant to go back.

You can ‘shade’ the wireframe to get an idea of what the finished item will look like. It’s ok but not wonderful.

Into the Third Dimension

In addition to 2D work, CorelCAD also allows you to work with 3D objects. You can extrude a 2D surface to produce a 3D box, create spheres, wedges, cylinders, etc. and you can operate on them to generate holes and interiors. You can also create fillets and so on and ‘loft’ surfaces to generate 3D objects. I’m no architect, but I can see how this will work well for architectural designs in the traditional AutoCAD manner.

However, for 3D mechanical designs, there are some issues.

The first problem I had was to create a hole. Simple holes are fine, if a little unintuitive (you subtract a cylinder from a solid object), but what about an M3 machine screw hole with an 82 degree countersink? Or an M6 counter bore? Not so easy – ideally, I want a ‘hole’ menu which allows me do a number of common hole type operations. I would think that it is possible to create functions like this in CorelCAD by programming (in LISP) a routine that does exactly what you want. But I want to get on with designing my machine – not writing LISP scripts.

CorelCAD mainly operates in wire-frame mode. Typically, you would start off with a 2D ‘layout’ of a 3D design, and then extrude and move parts to where they need to be, while the display remains in wire-frame. Wire-frames, though, strike me as something of a throwback to the days when graphics cards and CPUs were not powerful enough to fully render 3D objects in real time. Times have changed and I prefer working in a fully rendered, rotatable 3D view all the time as in the Solidworks/AutoDesk Fusion 360  type of 3D CAD software. With these you create a 2D ‘sketch’ on any surface of an existing fully rendered 3D object and extrude 3D shapes from the sketch – to my mind a much more intuitive approach.

The new QuickInput system allows you to specify dimensions ‘on screen’ rather than using the command line.

An important feature that CorelCAD is missing for 3D work is ‘assembly’. In producing a full 3D ‘model’ of a robot, say, you would typically have a number of parts – ‘components’ – designed separately; and you then want to bring them all together as a fully functional composite object. So, you really want to be able to select a gear shaft, say, and the center of a the hole in a gear and ‘join’ them, so that they align exactly, can rotate freely about a common axis and can then be moved and placed as one component. CorelCAD does have object ‘snaps’ where you can move an object to, for example, a position close to the middle of a line and it will snap to the mid-point. But this isn’t really the same as an assembly function. For me, assembly is essential. In researching which CAD package to use for designing robots,  I’ve tried several CAD packages without assembly and it takes far longer to produce a workable model than with a CAD package with it.

This is an example of a standard CAD file made available for download by a manufacturer (in this case igus  - Because CorelCAD works in native DWG format, importing files like this works perfectly.


If you want to use CorelCAD for architecture, planning, office layouts or individual component design, assembly may be pretty much irrelevant. CorelCAD is excellent at producing 2D drawings and plans and it’s also good at 3D architectural designs, but there are better products available for complete mechanical designs.

But there is one more feature of CorelCAD that you might like to consider: it has a ‘perpetual’ license. Many CAD systems – AutoCAD and SolidWorks, for example – require you to pay a yearly rental or subscription fee. For this you get the benefits of bug fixes, support and the latest releases of the software. You might think (as I do) that this is fine for the software vendor but not so good for those people who just wants to purchase something once and may consider upgrading after a few years. The CorelCAD perpetual license means that once you buy it, it’s yours to keep.

To get a really good view of what you’re working with, you have to ‘animate’ the view. This is what I would like to work in all the time, but when you ‘animate’ a model, all you can do is rotate it and admire it. You cannot alter it while in this mode.

The Good

1)    excellent  at 2D designs, layouts, drafting and drawings
2)    works in DWG as native format and is cheaper than AutoCAD
3)    imports and exports to CorelDraw and other Corel products
4)    perpetual software license

The Bad

1)    importing from CorelDraw did not work well for me
2)    mainly wire frame mode
3)    old fashioned help system with limited tutorials
4)    no assembly

…and the ugly?

No. CorelCAD is fine, as long as you are aware of its strengths and its limitations and use it appropriately. It is an excellent CAD package aimed at the AutoCAD (as opposed to full blown 3D design like SolidWorks) market. If you mainly want to produce 2D designs and 3D architectural drawings, it will serve you well. The 3D design functionality is adequate but if 3D mechanical design is your main purpose, there are better, more modern alternatives. But it’s a lot cheaper than AutoCAD (which currently costs £1,506 per year!) and it has a perpetual license. In short, I’m happy to design components and produce 2D layouts with CorelCAD, but I wouldn’t want to design a jet engine in it!

Thursday, 2 November 2017

Constructors in C#

C# (C-Sharp) is an object oriented programming language or OOP for short. Many modern language such as C++, Objective-C, Java, Ruby and Python are also object oriented. You can think of an object as a sort of package that wraps up data – that’s variables, such as strings and numbers – and behaviour – that’s functions or methods that do something, often by manipulating an object’s internal data.

The definition of an object is called its class. You can think of a class as a blueprint for an object. It’s just like the blueprint for a car. The blueprint defines all the fundamental features of a car but you can’t actually drive the blueprint. To use a car you have to create one based on the blueprint’s definition. That’s what you do in programming too. You write a class and you create usable objects from it. In fact, just as you can create many cars based on a single blueprint, so you can create many objects based on a single class.

When you create a new object from a class, you can call that class’s constructor to initialize the object. A constructor is a method that has the same name as the class itself. This class is called MyClass, so the constructor method will also be called MyClass.

public MyClass( ) {

The constructor has to be public – that is, it has to be visible to code outside the class itself – because clearly I need to call the constructor method from other parts of my program, whenever I want to create a new MyClass object.

A constructor doesn’t have to have any parameters. However, when an object has some internal fields, it is quite common for the constructor to define a list of parameters to initialize those fields. In that case, when you invoke the constructor, to create a new object, you would need to pass the appropriate arguments to initialize those fields. When an object descends from another object and the object from which it descends has a constructor that initializes some fields, the descendent class’s constructor can call the ancestor class’s constructor, passing to it any arguments required by the ancestor constructor to initialize its fields. It does that by putting a colon after the parameter list of the constructor, then the keyword base, then a comma-separated list of arguments between parentheses.

This short video (taken from my course ‘Learn C# Programming (in ten easy steps)’ gives a few more details about C# constructors.

This course was first created in 2012 but now, in 2017, it has been completely remade. Every single video has been re-done and no less than 86 new video lessons have been added. What’s more, students can also download the entire version 1 of the course (almost 4 more hours of video) as an added bonus. This is what the course contains:

  • 117 video lessons
  • 7 hours, 7 minutes of video
  • 32 sample projects
  • 10 quizzes
  • 89-pages of pdf documentation
  • PLUS: The entire version 1 course as a free download!

The regular price for this course is $145. But use the link below to sign up for just $35 (valid only until the end of 2017, so don’t wait!)

Wednesday, 1 November 2017

C Programming - Arrays, addresses and pointers

#include <stdio.h>

int main(int argc, char **argv) {
char str1[] = "Hello";
char *str2 = "Goodbye";
// str2 = &str1;
// str2 = str1;
printf("%d %d %s\n", &str1, str1, str1);
printf("%d %d %s\n", &str2, str2, str2);
return 0;

Let’s now look at how pointers and addresses work in C – and why arrays are special. In the code shown above I declare two string variables, str1 and str2. You can create string variables using either syntax but you need to understand that these two variables are by no means the same as one another. The first, str1, declared with a pair of square brackets is an array. The second, str2, declared using the star operator, *, is a pointer. As we know (see previous article), an array and an address are equivalent. So str1 is the address at which the array of characters in the string “Hello” are stored. But str2 is a pointer whose value is not the string “Goodbye” but the address of that string. So str2 'points to' the address at which the characters “Goodbye” are stored.

This should be clearer when you run the code.

When displayed as an integer value, the address of str1 (returned by the & address-of operator) is the same as the value of the variable str1 itself. That’s because str1 is an array - and an array is, in effect, an address.

But the address of str2 (returned by the & address-of operator) is different from the value of the str2 variable. Here the address gives us the location in memory of the pointer variable, str2. But the value of that variable is the address of the array of chars to which it points.

str1 is the location of the start of this array of characters, “Hello”, in computer memory. The address of str1 is the location where that string of chars begins.

But the value of the pointer variable str2 is a number that gives the location of the start of the array of characters “Goodbye” in computer memory. The address of str2 is the location where the str2 pointer variable is stored – and if we just want to get at data in the array, the address of the pointer variable itself is of no interest to us. For now, I’m only interested in the address of the array to which this pointer points. The value of str2 is the address of that array: the address of the first character in the string “Goodbye”.

The video below is taken from my online course, Advanced C Programming: Pointers. You can subscribe to this course, for a limited period, and save 63% by clicking this link. This lets you join up for $35 (regular price is $95):

Monday, 30 October 2017

C Programming – Arrays and Pointers

One of the things I’ve discovered, through teaching C programming, is that many students find it extremely hard to figure out how arrays work. In most modern programming languages, arrays seem to be simple lists of items like a virtual filing cabinet with numbered drawers for storing things. But that’s quite a ‘high-level’ abstraction of an array. C doesn’t do arrays like that.

In C, you are forced to deal with the way the computer actually stores these items in memory. And that’s when you discover the surprising fact that an array – or a string – is an address. That’s right. It is a memory location. What? But how can that be…?

Let me explain. The address of the array is the same as the address of the first item in the array. To understand this, let’s look C strings. C does not have a dedicated string data type. In C, a string is an array of characters that are terminated by a null character ‘\0’.

Consider this short program:

#include <stdio.h>

int main(int argc, char **argv) {
char str1[] = "Hello world";
printf("%s %c %d %d %d\n", str1, str1[0], &str1, &str1[0], str1);
return 0;

First it displays string – that is, the array of characters – of the variable str1, then the character at index 0, that is, at the first index of the array which here is H of ‘Hello world’. Then it shows the address of the array, which is this number representing a memory location (here, I am using %d in the format string to show it as a decimal value, but many compilers prefer you to use %p to show a hexadecimal value). Now I get the address of the first character. Remember that I said that the address of the array is the same as the address of the first item in the array. Well, if you run this program you will see that is true because the address of the character ‘H’ (which is shown when I use the ampersand ‘address-of’ operator) is the same as the address of the string, shown when I use the address-of operator with the string variable, str1. But look at this last value here. Instead of using the ampersand to get an address, I just display the variable itself, str1, as an integer using %d in my format string. And this shows the same number – the address of the array.

The address of an array is the same as the address of the first item in the array. Because it’s where the array begins. And the name of the array – that is the name you give to the array variable – is also the address of the array.

In other words, we may tend to think of arrays as fixed-length lists. And in many other programming languages, that may be all you need to know about arrays. But, in fact, an array is really the same as an address in memory that defines the beginning of a list of data items. So when you deal with arrays, including strings, you are dealing with addresses.

The video below is taken from my online course, Advanced C Programming: Pointers.

Save 63% by clicking this link to subscribe to the course for just $35 (regular price is $95):

Sunday, 22 October 2017

Clearing the Junk out of Windows

How my disk defragmenter led me to find and delete millions of unwanted files cluttering up my hard disk!

I’ve spent the last three weeks defragmenting my hard disk. Yes, really!  And along the way I’ve discovered that I had several million useless files clogging up the disk in hard-to-find, difficult-to-delete subdirectories.

It all started when I decided to move all the programs and files I use most often onto a new PC and leave my old PC free for testing and reviewing software. It seemed to go pretty well until I decided to defragment my old PC’s hard disk. The PC’s startup time had been getting slower and slower over the years. Defragmentation was just one of the measures I took to speed it up. I first tried using the standard Windows defragmenter (right-click the disk drive in Windows Explorer, then select Properties/Tools/Defragment now). That was not only horribly slow but, to make matters worse, it provided very little feedback to show what, if anything, was being defragmented.

Windows Defragmenter - it does the job but is far from informative!

So I tried out Piriform’s free Defraggler instead. This wasn’t exactly quick either but at least it showed me what it was doing. It displays a colour-coded representation of your disk, showing fragmented files, unfragmented files, when data is being read and when data is being written. It also shows a list of fragmented files and you can optionally defragment selected files. The only trouble was that Defraggler got stuck in the initial analysis stage of defragmentation. It showed it had analysed 100% of my disk and then just stayed there, constantly busy, but continuing to show 100%. I suspected that it was stuck analysing a specific set of problematic files, but I didn’t know which ones. Clearly I needed to know which files were taking up most of my disk space.

Defraggler - a free tool that shows you what it's doing!
The rather good free disk mapping too, TreeSize, helped out here.  This draws a map of your disk sorted by the directories containing either the largest amount of data or the largest number of files. It took quite a while to finish and I was prompted a few times to ask if I wanted to abort. But I stuck with it and eventually it showed me exactly what was causing all my problems.

TreeSize - a very useful disk-mapping utility
The folder c:\Windows\sysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5 contained over 11,000,000 files (yes, I really do mean eleven million!) while c:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5 contained another three million. Where the heck did they come from?

It took me a while to figure it out. Then I came across this article written by someone who had experienced a similar problem: That jogged a memory. Years ago – many, many years ago – I has used the Fusion Assembly Binding Log viewer (Fuslogvw.exe) to help the debugging of some software my company was then developing.  This tool keeps track of DLL loading and it writers a tiny HTML file to store each bit of information. This article explains this:

I’d forgotten all about Fuslogvw. And over the years it had been busily writing files, millions of files, that I neither needed nor even knew were there. To stop it doing so, I just went into the Registry Editor and disabled it. This explains how to do that:

OK, so maybe my problem is pretty obscure. But it illustrates a more general problem when doing disk intensive operations such as backups and defrags. Namely: the more files you have, the longer the backup or defrag takes. And millions of files, as I had, can really slow things down. The obvious solution is to delete them. But how?

Using Windows Explorer to delete this number of files is incredibly slow. Besides which, in special Windows system directories you may need Admin privileges. The solution then is to load a command prompt (Windows Menu/All Programs/Accessories/Command Prompt) – but don’t just click Command Prompt. Right-click it and select ‘Run as administrator’. Then navigate to the directory containing all the unwanted files and enter del *.*

Urgh! But deleting files this way is incredibly slow and it gives you no information on whether or not any files are actually being deleted. My solution to that was to write a simple batch file that deleted all the files ending with .htm alphabetically (first delete those starting with ‘A’, then ‘B’, all the way up to ‘Z’, then all those starting with ‘0’ up to ‘9’…) and showed me the times when each group of files had been deleted. That didn’t speed up the file deletion but at least it gave me peace of mind to know that something really was happening. Here’s a short fragment of that batch file to show what I mean:

time /t
del A*.htm
time /t
del B*.htm
time /t
del C*.htm
time /t

Anyway, it took me about three days (night and day) to delete those files. Once I’d done that I ran Defraggler again and this time it got on with the job pretty effectively. Along the way, I discovered a whole load of other directories containing unneeded junk. For example, some programs which I had long ago uninstalled, had left all kinds of stuff under \ProgramData. I duly removed  them. I’m not providing any details, however, since some apparently unneeded files under \ProgramData and other ‘system’ folders may be important and I don’t want to be blamed for encouraging you to delete anything that may cause problems. When you go hacking around in these directories you are on your own! But if, like me, you are frustrated by the slow speed of your defragging or disk backup programs, you may want to take a look, using TreeSize, to see if your disk space is being taken up by junk you didn’t know about. You’ll almost certainly find that it is!

Thursday, 5 October 2017

VEGAS Pro 15 Review

VEGAS Pro 15 Edit – € 399 / $399 / £299
VEGAS Pro 15 – € 599 / $599 / £499
VEGAS Pro 15 Suite – € 799 / $799 / £649

If you’ve used VEGAS before, the first thing you’ll notice when you load the new version is that it looks nicer. I’ve criticized VEGAS before for its rather inelegant and screen-hogging user interface so I am pleased to see that version 15 gets rid of some of the unnecessary clutter.

For a general overview of VEGAS see my previous review of VEGAS 14.

The user interface has redesigned icons, full-colour timeline tracks and the addition of four switchable colour schemes. As in previous releases, you can tailor some elements to taste – for example, by selecting alternative track colours. A new feature lets you switch the overall colour scheme of the entire user interface from a choice of four: Dark, Medium, Light or White. However, there is no way of previewing the colour-scheme change when you make it. Any change you make is only applied after you restart VEAGAS which, let’s be frank, is hardly the final word in user-friendliness!

In an attempt to reduce clutter, some new context-sensitive menu configuration tools (called, ‘hamburger’ buttons) have been added. These buttons are shown as three horizontal lines which appear on various UI elements such as the video preview window, the track panel and also in the top right-hand corner of individual video and audio clips. When you click the hamburger button a drop-down menu appears from which you can select various options. For instance, in the video preview window the hamburger menu shows items to go to the next or previous frame, to the start or to the end. In the track pane, it pops down a cascading menu to let you track motion, bypass motion blur, select a compositing mode and various other arcane options. If you decide that you need these features frequently and want a faster way of getting at them you can add them as icons to the window or tool itself.

Hamburger buttons have been around for a while – they are often used in mobile apps and web sites to hide functionality and keep the interface ‘clean’. Some users hate them. I have to say, though, that the way they are used in VEGAS (to hide less frequently used options or configure the selected track or window) they seem to me to be a reasonable way of keeping the user interface under control.

Notice the ‘hamburger’ buttons that provide menus from both the preview window and individual media clips
You can also rearrange the windows and the pages on tabbed panes by dragging them and dropping them into selected areas of the workspace. To redock an undocked pane you have to hold CTRL while dragging. Once you’ve created a layout you like you can save it by name or you can select from one of the redefined layouts – this is just as well as I found that it takes quite a bit of trial and error to redock tabbed panes in exactly the place you want (I kept accidentally messing up the layout in my attempts) once they’ve been undocked!

But never mind the appearance, what about new and improved functionality? Top of my personal list of desirable features would be increased rendering speed, so I was pleased to see that this is one of VEGAS 15’s claimed improvements.

There is no simple way to benchmark the speed of video rendering. The size and format of the project media, the overhead due to any editing and effects that have been added, plus the rendering varying efficiency of different production settings and the specifics of your computer hardware setup all have an impact. Even so, I decided to run a very simple test to get some idea of the speed of video rendering.

I ran this test on a PC with 16Gb of system memory and a NVIDIA GTX 980Ti graphics card with 6 Gb of video memory. I tried rendering a single 5 minute 25fps 1920x1080 video clip, with no editing applied. I enabled the NVIDIA GTX GPU acceleration using the VEGAS Preferences dialog. In VEGAS 14 I rendered as Mainconcept AVC/AAC H.264 MP4 at the original video size (1080p). It took 8 minutes and 52 seconds to render.  With VEGAS 15 the same clip was rendered with MAGIX AVC/AAC MP4 (the replacement for the Mainconcept format). It took 8 minutes and 10 seconds to render. So, in short, not much difference. For the sake of comparison, I rendered the exact same clip in Cyberlink PowerDirector 15 (AVC H.264 MP4, 25fps, 1080p with its hardware video encoder enabled) and the entire video was rendered in 31 seconds. Yes, really! More than 7 and a half minutes faster than VEGAS 15.

You may need to go and take a break while your videos are rendered
Now, as I say, rendering results vary according to numerous different factors and it may be that for certain projects, with certain hardware and rendering settings, VEGAS can be made to render more efficiently. There is, at any rate, a long discussion thread about this here:

All I can say for sure is that, in long experience of video editing and producing, Cyberlink PowerDirector has by far the fastest video rendering of any program I’ve ever used. VEGAS 15 doesn’t, as far as I can see, offer any real challenge in this respect.

One thing I do like is the new interactive sizing and cropping of video clips. Both Picture-in-Picture and Crop editing have been improved so that you can, for example, modify the size and position of a video clip that overlays another clip. For instance, if you have a video clip showing some scenery or a tutorial of some sort and you want to overlay a ‘talking head’ clip, you just drop the overlaid clip onto a new track and apply the ‘picture in picture’ plugin to it. This now lets you move and resize the overlaid clip right inside the video preview window. You can, of course, achieve the same results by panning and cropping the overlaid clip as in earlier VEGAS releases. But traditional VEGAS pan/crop has to be applied in a popup dialog so the new interactive PIP tools add an extra level of convenience. The Crop plugin works in a similar way. You start by dropping Crop from a list of plugins onto a video track. In order to do the actual cropping you have to pop up the Crop dialog box and then you can either make adjustments using sliders or you can drag the edges of the video clip in the preview window.

If you add a video overlay, you can use the Picture In Picture plugin to alter its size, position and rotation either using a dialog box or by dragging and dropping the overlay using the mouse
There are numerous other enhancements to tools throughout this release. These include the ability to selectively paste event attributes’ (such as an audio pitch shift, transitions or pans and crops) from one clip to another. And you can automate video rendering and uploading to YouTube, Facebook or Vimeo.

There are improvements to colour grading using lookup tables and enhanced titling capabilities. An expanded range of 3rd party plugins has been provided (for the Pro and Pro Suite editions). These include plugins some of the best known suppliers – BorisFX, HitFilem and NewBlueFX. You can find the full range of improvements and additions listed online along with a number of short video demos and tutorials:

In summary, this release of VEGAS has some useful improvements both to functionality and interactivity. But it has both the strengths and the weaknesses of earlier versions. Its ability to chain together multiple effects, for example, and tweak individual parameters in the ‘effects chain’ provides a high level of editing control but the downside is that this means that you have to do a lot of work in popup dialog boxes which can be quite fiddly and time-consuming. And its video rendering speed may have been improved a bit but it is still far from being a speed-demon. So if you need precise editing control and don’t mind the extra time it takes to edit and render, VEGAS has a lot to offer. But if you just want to get a whole load of videos edited and uploaded as rapidly as possible, VEGAS may not be the best choice.

Wednesday, 20 September 2017

C Programming for Beginners: Operators

This is part 4 of my series on C programming for beginners. (See also part 3)

In your programs you will often want to assign values to variables and, later on, test those values. For example, you might write a program in which you test the age of an employee in order to calculate his or her bonus. Here I use the ‘greater than’ operator > to test of the value of the age variable is greater than 45:

if (age > 45) {
bonus = 1000;

Operators are special symbols that are used to do specific operations such as the addition and multiplication of numbers. One of the most important operators is the assignment operator, =, which assigns the value on its right to a variable on its left. Note that the type of data assigned must be compatible with the type of the variable. This is an assignment of an integer (10) to an int variable named myintvariable:

int myintvariable;
myintvariable = 10;


Beware. While one equals sign = is used to assign a value, two equals signs == are used to test a condition.

= this is the assignment operator.
e.g. x = 1;

== this is the equality operator.
e.g. if (x == 1) 


C can perform tests using the if statement. The test itself must be contained within parentheses and it should be capable of evaluating to true or false. If true, the statement following the test executes. Optionally, an else clause may follow the if clause and this will execute if the test evaluates to false. Here is an example:

if (age > 45) {
bonus = 1000;
} else {
bonus = 500;

You may use other operators to perform other tests. For example, this code tests if the value of age is less than or equal 70. If it is, then the conditional evaluates to true and "You are one of our youngest employees!"  is displayed. Otherwise the condition evaluates to false and nothing is displayed:

if (age <= 70){
printf("You are one of our youngest employees!\n");

Notice that the <= operator means ‘less than or equal to’. It performs a different test than the < operator which means ‘less than’. These are the most common comparison operators that you will use in tests:

== // equals
!= // not equals
> // greater than
< // less than
<= // less than or equal to
>= // greater than or equal to


Some assignment operators in C perform a calculation prior to assigning the result to a variable. This table shows some examples of common ‘compound assignment operators’ along with the non-compound equivalent.

operator                    example                       equivalent to
+= a += b a = a + b
-= a -= b a = a - b
*= a *= b a = a * b
/= a /= b a = a / b

It is up to you which syntax you prefer to use in your own code. Many C and C++ programmers prefer the terser form as in: a += b. But the same effect is achieved using the slightly longer form as in: a = a + b.

I’ll explain prefix and postfix operators in the next article. And if you want to learn C in more depth, why not sign up to my online video course – C Programming for beginners. See here: