80-Bus News


November-December 1984, Volume 3, Issue 6

Page 28 of 55


I do not intend to give a detailed description of the language here as it would be too long and boring but if I can try to conjure up the flavour of "The -C’ programming environment” as the yanks call it, I think that would serve my purpose better. If by some miracle these documented mumblings generate some enthusiasm then I recommend that you go out and buy the standard text book for any -C” programmer, that is "The -c’ programming language" by Brian Kernighan and Dennis Ritchie published by Prentice-Hall. It is quite good for a computing textbook, and what is more, defines the standard to which all compiler writers strive, and all available compilers are compared. Better still borrow it from a friend as it probably costs about £19 by now.

Ok, enough of the preamble, lets get our hands dirty and walz straight into a *C’ program. This will not shock the computing world with its complexity but is a program to open a disk file and write the value of a loop counter into it.

€include "stdio.h" /* include standard I0 header file fron disk */

int count; /* declare a 16 bit integervbl */ FILE *fd; /* declare file descriptor */ main() printf("A -C* program\n"); /* print opening message */ openit(); /* call function to open file */ wrt_nums(); /* call function to write to file*/ printf£("Program terminating\n"); /* print end message */ fclose( fd); /* weite buffers & close file */ exit(0); /* call exit routine */ } openit() /* function to open trivia file */ { fd=fopen("A: TRIVIA. DAT" ,"w") ; /* pass name & mode to fopen func*/ printf("Trivia file: "); /* display file id */ if(fd == NULL) /* is the file open sucessful */ { printf("open error"); /* No – so print error message */ exit(0); /* ... and terminate program */ } else printf("open ok\n"); /* file opened ok, so tell em */ } wrt_nums() /* writes value of count to disk */ {

for(count=0; count<=100; count++) putw(count, fd);


So having looked at it what do you think, I know that I have been using -c’ for a while now and I’m pretty used to it, but is it really as mumbo jumbo’ish as some people say?

This is an OCR’d version of the scanned page and likely contains recognition errors.

Page 28 of 55