Frequently Asked Questions


Do you know anything about compilers?
Yes. I have done both of the compilers courses currently offered by the Computing Science department and have done some work on GCC.
Can you help with ...
Probably. Whether I will or not is another question. A couple of years ago I put together a web page with some basic info on writing compilers, flex, et al. During tutorials I questions about C will take priority over questions about flex, symbol tables, parsers, etc. - if I have time I will try to answer them.


What is ANSI C?
ANSI is the American National Standards Institute. Like ISO (International Standards Organisation) and BSO (British Standards Organisation) they work to create, distribute and promote standards in business practise. One of the areas they cover is IT and programming languages and one of the standards they have produced is for C.
How can I get a copy of the ANSI standard?
Via the magic of Athens you can acquire a PDF version. Be warned that it's quite... comprehensive:
  • Acquire an Athens username and password (see you subject librarian)
  • Log in to Athens
  • Follow the link to the BSO (British Standards Online).
  • Search for standard number 9899. You should get several consecutive versions of the standard.
  • Pick the one you want and log in using Athens username and password
How different is ANSI C to what we are being taught?
Not very. If you have good coding style, lay out your programs clearly and formally and get the code to compile without giving warnings then you are probably not far off.
Do we need to use a different program to compile ANSI C?
No, gcc has an ANSI C compatability mode (which is mostly compliant with the standard). Use the '-ansi' flag to turn on compatability, use '-pedantic' as well if you want the compiler to reject any code that it doesn't feel is ANSI compliant.
Why aren't we being taught ANSI C first?
Good question. What you are being taught is mostly ANSI C, presumably there was a trade off made between strict adherence to the standard and any extra complication and complexity it might cause.
Do we need to be aware of the standard?
Yes. Even if it doesn't directly gain you any marks in the exam it will help your understanding of C, plus if you ever program C professionally it will useful.
Do we need to read all 557 pages of it?
Probably not for this course. That said reading sections of it will do you no harm...

Basic Stuff

Which book do you recommend?
I can't speak authoritively on this as I don't own any of the recommended texts but 'The C Programming Language' is generally held in high regard and I've heard some folks saying nice stuff about 'A Book on C'. As a general recommendation I'd say O'Reilly Publishing is normally good. To be honest as long as it covers functions, pointers and dynamic memory allocation (ideally header files / modularity, makefiles and structured data types as well) then it doesn't matter which book you get - it's far more important that you read it and practise.
What makes you think you're qualified to teach us?
I've been programming C and C++ for the past 6 years and worked as a proffesional programmer for both the Ministry of Defense and the University of Bath. This is now the 3rd year I have tutored this course. Hopefully one day I will have time to publish some of my pet projects and then you will be able to assess for yourselves whether I can program.
I heard you managed to teach someone C in a day. Can you do that with us so we can skip the rest of the course?
I may be capable of this but spending 2 hours a week on it for the whole term is a much better way of doing it. Besides you don't want to know what I charge for service like that :-)
Why don't you like Windows?
I dislike Microsoft because of their attitude towards the computing industry and academia, their illegal business practises and their low quality products. Although their site is a little evangelical some good points are made here.
Will you teach me / us about graphics / compilers / operating systems / networking etc. ?
I can give you some pointers and if the whole group gets far enough ahead / through the set work I'll happily talk about some of the issues I think are interesting / some more fun stuff to practise you programming on. (It may be of interest to note that it is recommended you do the coursework for the second year compilers course in C and compilers are one of the things I'm particularly interested in.)


Why do you suggest we use gcc -Wall hello.c -o hello while in the notes it says gcc hello.c -o hello ?
I found using -Wall which turns on all of the warning functions in gcc very helpful and wished I'd been told about it sooner. It issues warnings about lots of things that are often not errors (technically speaking) but are probably not what you meant; it should help you develop a better coding style.
Why do you always type ./hello while the notes say hello will run OK?
When you are using bash (the thing that gives you the amos$ prompt) the first word in any command is the program you want to run. If it is not the complete address (in the filesystem) of the command then bash looks in a series of places for a file with the appropriate name (echo $PATH lists the places it looks). Traditionally . (the current directory) isn't in the list of places searched because then if you are working in a directory owned by some nasty miscreant and they have programs named the same or similar to common commands then you could end up running their code - not the program you meant (and thus doing whatever they want). Running hello runs the first program bash finds called 'hello' where as ./hello runs the program called hello in the current directory (IE what you've just compiled). This may seem rather pedantic (and in many ways it is) but you did ask why I do it.
Do you have a suggestions on how to write better code?
There are some here.

Fun to take home!

How can I work from home?
(The advice that follows is for Windows users; Linux, *BSD and Mac OS X users will likely already have, or can easily install all of the tools that are on the BUCS servers, they are also likely to have tools like ssh). There are a number of way, listed in terms (IMHO) of decreasing simplicity
  1. Use SSH to connect to the BUCS servers. This is by far the eaiset way, see the BUCS FAQ on the subject. If you believe in browser applets, this is a zero install solution. As noted here unless you install eXceed you will be unable to use programs that use a separate graphical window. A quick work around it to use a simplier editor, such as pico.
  2. Use a Linux (or other UNIX) live CD. These are full operating systems that run from a CD and require no installation. Many come with gcc and other C development tools.
  3. Installing Windows native version of GCC. As the authority in Redmond decided that it was a good idea to sell you an OS without a compiler. This page may give you some starting points - there isn't really a simple solution.
  4. Install Cygwin - it is a full UNIX emulation layer for Windows and thus more solution than the problem requires (IMHO).
Why do you say people shouldn't use notepad / my_favourite_windows_text_editor to write C?
Back in the dim and distant past there was a device called the tele-type. It was an automated telegraph machine and very successful. It received and printed 10 characters a second. However it took 2/10 of a second to move the writing head down and to the start of the next line. Consequentally some bright spark decided to use two characters to represent a logical end of line (ASCII 10 - 'new line' followed by ASCII 13 - 'carrage return') - the first started the head moving and the second was lost while it moved; but it didn't matter. This convention passed into early computer systems and to CPM. CPM begat DOS, DOS was transformed into a monsterous twisted thing Microsoft DOS, Micorosft DOS begat Windows 1, 2 and 3 (although the first lead very un-eventful lives), on reaching 3.11 Windows begat Windows 95 and the line decended into degeracy, Windows 3.11's half cousin (who was actually descended from VMS but that's another story in itself) was Windows NT which begat Windows 2000 which begat Windows XP and so on. The point is that this convention hasn't died out, text files in windows still use two characters for an end of line. UNIX was based on a much more 'exactly what it says on the tin' philosopy (or is it the other way around) and only used one character for end of line. Where you want a new line - you put a new line character - simple as that. This small difference is the source of much irritation. This is why text files created on UNIX systems tend to look strange in Windows editors. Most windows editors are rather arrogent and assume that if you're not using the windows convention your file is broken and helpfully 'fix' it for you. When these are moved back to UNIX machine most tools just ignore the extra characters (or display them as junk - which they are) however it can cause excessive hassel. Avoiding doing this is by far the easist solution. Alternatively look at the unix2dos and dos2unix commands.
Can I use >insert-favourite-development-suite-here< instead of gcc?
Practise with another development system is better than no practise at all but the amount of support I can (and will) offer for that is a lot more limited. Plus when it comes to assessment you will be using the university UNIX machines. If at all possible you're best off getting your head around the recommended tools.
Why don't we have an IDE?
IDEs are a useful tool to help people who already know a language. For beginners they reduce the portability of the skills you learn, confuse application and language and obfuscate some of the basic concepts of what you are doing. (The other answer is - you do - emacs and UNIX - you just have to bother to take the time to learn how to use them).
What's this Cygwin thing then?
Cygwin is a UNIX emulation layer for windows. It gives a reasonably standard set of UNIX tools and environment on a Windows machine. This includes a copy of gcc and the tools to use it.
Where can I get it?
Strangely enough, it is free as in freedom and thus will cost you nothing.
How do I set it up?
I would suggest you don't. Cygwin is a solution to a larger problem than simply developing simple C programs on a Windows machine. Connect to the BUCS UNIX machines - it is much easier. Failing that consider a Linux live CD such a KNOPPIX, only install Cygwin as a last resort.

Non questions

Programming is really difficult.
This isn't a question but I'll pretend it is for now. Yes - when you start programming is difficult and you will spend lots of time getting it wrong - if you don't you're probably not learning. The *ONLY* way to get any good at programming is to practise. It will help, it will get easier, it will get faster, it will make the rest of your coursework easier, it will get you a better job.
UNIX is difficult.
See the previous question. It continually amazes me that people think using computers should be immediately obvious to them. You don't expect to be able to fly a plane, control a speed boat, use a chainsaw or even cook without 1. recieving some form of instruction, 2. practising - computers are very complex devices why should they be any different.
I work better at home.
This may be true but I'd still suggest working during the tutorials. If found in person or e-mailed (I know my e-mail address isn't on this site but I'm guessing you're bright enough to figure it out) inbetween tutorials I will try to help but this is my 'free' time so I can't guarentee that I'll have time to help - if you ask during a tutorial then I will do my best.
Do you know any good jokes about C?
Well it's strange you should mention that because Mr. Mead sent me one the other day:
Okay so there's these two strings, right
They walk into a bar
The first string says
Hello, I'd like a rum and cokerhe7954454gh2kjn.,.43>>[][]21?24
The second string says
You'll have to excuse my friend, he's not null-terminated