strcpy or fun with pointers, a while loop and cstrings

ps1 and ps2 are pointers to a character array, what does this do?
while (*ps2++=*ps1++);

It is my favorite example of bizarre looking C code which utilizes pointers, pointer increments, unary operation precedence, C-string null termination and the evaluation of an assignment. Breaking it down a little "*ps2++=*ps1++" means the same thing as this:
*ps2 = *ps1;
ps2++;
ps1++;

Since ps1 and ps2 are character pointers the first line dereferences each and sets the value of ps1 to the memory pointed to by ps2. The second and third lines just increment each pointer. Both are pointing to character arrays, so they now point to the next character in the array.

The final important detail is that a cstring ends with a null terminator. So eventually the loop will get to the strings end and assign "'\0' = '\0'", which evaluates to '\0', which is false. Thus ending the loop.

Here's a full example:


Here it is in the form of strcpy (from wikipedia):

Linux Automated Backup

I've been wanting to setup some sort of automatic backup on my personal data for quite some time, but have always settled on manually copying important documents to a second hard drive. Well thanks to THIS nice guide to setting up rsync and cron I now have it setup.

Short guide shorter:

1) Create a bash script with the following (note there are only two lines below, the command is long):

#!/bin/bash
sudo rsync -av --progress --delete --log-file=<location to put log file>/$(date +%Y%m%d)_rsync.log <directory to backup> <directory to put backed up directory in>

2) Run "sudo crontab -e" and enter the following line to have your backup done every morning at 4am:
0 4 * * * /root/rsync-shell.sh

Showing Gnome Workspace Names

One of my favourite things in Linux is having multiple workspaces. Something I didn't know until recently is that you could name your workspaces, and with a simple trick have the name displayed on your top or bottom panel.

New Project Smell

Took the first steps on a new project, an automatic cat feeder. The plan is to have it completed by Thanksgiving so that the cats have something to eat while I'm out of town. That being said, I cut the pieces for the box out of some 1/4" MDF and have a lot of work to do.

Automatic Cat Feeder - Pieces

Taking Stuff Apart: 8mm Projector

More treasures from the landfill, this is something I took apart a year or two ago. The only reason its still kicking around is because of the motor, which will be re-purposed in another project someday. There's nothing left to identify what model it is, anyone know?

There isn't much left for the front. Everything interesting has been ripped out including an old bulb, lens and a switch. The bulb's reflector was actually used in another project. In the top corners are a couple spokes which were probably used to attach the reels, film would go through the slot in the bottom right where the bulb and lens used to be.
8mm projector 1