Home » Recent acquisitions » Acorn ADFS disks » adfs_ArchimedesWorld_199201.adf » January92 » !AWJan92/Goodies/AllAtC/Work/c/words

!AWJan92/Goodies/AllAtC/Work/c/words

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Recent acquisitions » Acorn ADFS disks » adfs_ArchimedesWorld_199201.adf » January92
Filename: !AWJan92/Goodies/AllAtC/Work/c/words
Read OK:
File size: 0352 bytes
Load address: 0000
Exec address: 0000
File contents
/*  Program: !Words                       */
/*  Archimedes World, January 1992.       */

#include "lexical.h"
#include <stdio.h>

int main( int argc, char *argv[] )
{
    word   list = NULL;
    int    len;
    string buffer;
 
    if ( argc == 1 )
        puts( "Usage: Words <filename>" );
    else
    {
        FILE *in = fopen( argv[1], "r" );

        if ( in )
        {
            while ( len = GetWord( buffer, STRLEN, in ), len )
            {
                if ( len > 1 )
                {
                    ToLowerCase( buffer );
                    StoreWord( buffer, &list );
                }
            }

            fclose( in );
            puts( "\nWords in sorted order:-\n" );
            ListWords( list );
        }
        else
            printf( "Cannot open file '%s'\n", argv[1] );
    }
    
    return 0;
}




00000000  2f 2a 20 20 50 72 6f 67  72 61 6d 3a 20 21 57 6f  |/*  Program: !Wo|
00000010  72 64 73 20 20 20 20 20  20 20 20 20 20 20 20 20  |rds             |
00000020  20 20 20 20 20 20 20 20  20 20 2a 2f 0a 2f 2a 20  |          */./* |
00000030  20 41 72 63 68 69 6d 65  64 65 73 20 57 6f 72 6c  | Archimedes Worl|
00000040  64 2c 20 4a 61 6e 75 61  72 79 20 31 39 39 32 2e  |d, January 1992.|
00000050  20 20 20 20 20 20 20 2a  2f 0a 0a 23 69 6e 63 6c  |       */..#incl|
00000060  75 64 65 20 22 6c 65 78  69 63 61 6c 2e 68 22 0a  |ude "lexical.h".|
00000070  23 69 6e 63 6c 75 64 65  20 3c 73 74 64 69 6f 2e  |#include <stdio.|
00000080  68 3e 0a 0a 69 6e 74 20  6d 61 69 6e 28 20 69 6e  |h>..int main( in|
00000090  74 20 61 72 67 63 2c 20  63 68 61 72 20 2a 61 72  |t argc, char *ar|
000000a0  67 76 5b 5d 20 29 0a 7b  0a 20 20 20 20 77 6f 72  |gv[] ).{.    wor|
000000b0  64 20 20 20 6c 69 73 74  20 3d 20 4e 55 4c 4c 3b  |d   list = NULL;|
000000c0  0a 20 20 20 20 69 6e 74  20 20 20 20 6c 65 6e 3b  |.    int    len;|
000000d0  0a 20 20 20 20 73 74 72  69 6e 67 20 62 75 66 66  |.    string buff|
000000e0  65 72 3b 0a 20 0a 20 20  20 20 69 66 20 28 20 61  |er;. .    if ( a|
000000f0  72 67 63 20 3d 3d 20 31  20 29 0a 20 20 20 20 20  |rgc == 1 ).     |
00000100  20 20 20 70 75 74 73 28  20 22 55 73 61 67 65 3a  |   puts( "Usage:|
00000110  20 57 6f 72 64 73 20 3c  66 69 6c 65 6e 61 6d 65  | Words <filename|
00000120  3e 22 20 29 3b 0a 20 20  20 20 65 6c 73 65 0a 20  |>" );.    else. |
00000130  20 20 20 7b 0a 20 20 20  20 20 20 20 20 46 49 4c  |   {.        FIL|
00000140  45 20 2a 69 6e 20 3d 20  66 6f 70 65 6e 28 20 61  |E *in = fopen( a|
00000150  72 67 76 5b 31 5d 2c 20  22 72 22 20 29 3b 0a 0a  |rgv[1], "r" );..|
00000160  20 20 20 20 20 20 20 20  69 66 20 28 20 69 6e 20  |        if ( in |
00000170  29 0a 20 20 20 20 20 20  20 20 7b 0a 20 20 20 20  |).        {.    |
00000180  20 20 20 20 20 20 20 20  77 68 69 6c 65 20 28 20  |        while ( |
00000190  6c 65 6e 20 3d 20 47 65  74 57 6f 72 64 28 20 62  |len = GetWord( b|
000001a0  75 66 66 65 72 2c 20 53  54 52 4c 45 4e 2c 20 69  |uffer, STRLEN, i|
000001b0  6e 20 29 2c 20 6c 65 6e  20 29 0a 20 20 20 20 20  |n ), len ).     |
000001c0  20 20 20 20 20 20 20 7b  0a 20 20 20 20 20 20 20  |       {.       |
000001d0  20 20 20 20 20 20 20 20  20 69 66 20 28 20 6c 65  |         if ( le|
000001e0  6e 20 3e 20 31 20 29 0a  20 20 20 20 20 20 20 20  |n > 1 ).        |
000001f0  20 20 20 20 20 20 20 20  7b 0a 20 20 20 20 20 20  |        {.      |
00000200  20 20 20 20 20 20 20 20  20 20 20 20 20 20 54 6f  |              To|
00000210  4c 6f 77 65 72 43 61 73  65 28 20 62 75 66 66 65  |LowerCase( buffe|
00000220  72 20 29 3b 0a 20 20 20  20 20 20 20 20 20 20 20  |r );.           |
00000230  20 20 20 20 20 20 20 20  20 53 74 6f 72 65 57 6f  |         StoreWo|
00000240  72 64 28 20 62 75 66 66  65 72 2c 20 26 6c 69 73  |rd( buffer, &lis|
00000250  74 20 29 3b 0a 20 20 20  20 20 20 20 20 20 20 20  |t );.           |
00000260  20 20 20 20 20 7d 0a 20  20 20 20 20 20 20 20 20  |     }.         |
00000270  20 20 20 7d 0a 0a 20 20  20 20 20 20 20 20 20 20  |   }..          |
00000280  20 20 66 63 6c 6f 73 65  28 20 69 6e 20 29 3b 0a  |  fclose( in );.|
00000290  20 20 20 20 20 20 20 20  20 20 20 20 70 75 74 73  |            puts|
000002a0  28 20 22 5c 6e 57 6f 72  64 73 20 69 6e 20 73 6f  |( "\nWords in so|
000002b0  72 74 65 64 20 6f 72 64  65 72 3a 2d 5c 6e 22 20  |rted order:-\n" |
000002c0  29 3b 0a 20 20 20 20 20  20 20 20 20 20 20 20 4c  |);.            L|
000002d0  69 73 74 57 6f 72 64 73  28 20 6c 69 73 74 20 29  |istWords( list )|
000002e0  3b 0a 20 20 20 20 20 20  20 20 7d 0a 20 20 20 20  |;.        }.    |
000002f0  20 20 20 20 65 6c 73 65  0a 20 20 20 20 20 20 20  |    else.       |
00000300  20 20 20 20 20 70 72 69  6e 74 66 28 20 22 43 61  |     printf( "Ca|
00000310  6e 6e 6f 74 20 6f 70 65  6e 20 66 69 6c 65 20 27  |nnot open file '|
00000320  25 73 27 5c 6e 22 2c 20  61 72 67 76 5b 31 5d 20  |%s'\n", argv[1] |
00000330  29 3b 0a 20 20 20 20 7d  0a 20 20 20 20 0a 20 20  |);.    }.    .  |
00000340  20 20 72 65 74 75 72 6e  20 30 3b 0a 7d 0a 0a 0a  |  return 0;.}...|
00000350  0a 0a                                             |..|
00000352