Congratulations to: * 2024/anders - Prize in sound coding - layered music generator * 2024/burton - Prize in pentagrammatology - wordle hard mode solver * 2024/cable1 - Prize in bot talk - LLM inference engine * 2024/cable2 - Prize in murky waters - salmon recipe * 2024/carlini - Prize in perfect timing - Intel 4004 emulation * 2024/codemeow - Prize in tray planting - bonsai generator * 2024/endoh1 - Prize in patient pointillism - slow ray tracer in CPP * 2024/endoh2 - Prize in solid body physics - rotating rigid body simulation * 2024/ferguson1 - Prize in diabolical logistics - Oregon trail pact with the devil * 2024/ferguson2 - Prize in yil-tas - Navajo code talker translator * 2024/howe - Nice accent eh-ward - mini vi * 2024/kramer - Prize in linguistic arithmetic - natural language numerical calculator * 2024/kurdyukov1 - Prize in phased periodicity - phase of the Moon * 2024/kurdyukov2 - Prize in art restoration - JPEG artifact removal * 2024/kurdyukov3 - Prize in virtual quietus - gaming VM and doom * 2024/kurdyukov4 - Prize in embiggening - encode without literals * 2024/maffiodo - Prize in creative interpretation - Jav\*script interpreter * 2024/mills - Prize in ℤ₃ - Infocom v3 story interpreter * 2024/stedolan - Best one liner - icon from MD5 * 2024/straadt - Prize in imitative rebooting - OpenRISC CPU and Linux * 2024/tmarrec - Prize in cyclonic coding - 3D tornado simulation * 2024/tompng - Prize in quasi bijection - vortex encryptor decryptor * 2024/weaver - Sur prize - rickroll Ran `make update` to perform the above. new file: 2024/burton/.entry.json
89 lines
1.9 KiB
C
89 lines
1.9 KiB
C
/*
|
|
* bytecount.c - writes the location of each string in a single char *.
|
|
*
|
|
* This version uses the source data file, data.src, and it reads one
|
|
* 'string' at a time; it does not read in the whole file at once.
|
|
*/
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <ctype.h>
|
|
#include <stdlib.h>
|
|
#include <getopt.h>
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
FILE *fp = NULL;
|
|
size_t len = 0;
|
|
char *buf = NULL;
|
|
char *filename = "data.src";
|
|
int k;
|
|
size_t i = 0;
|
|
|
|
while ((k = getopt(argc, argv, "i:")) != -1)
|
|
{
|
|
switch (k)
|
|
{
|
|
case 'i':
|
|
filename = optarg;
|
|
break;
|
|
case ':':
|
|
case '?':
|
|
exit(1);
|
|
break; /* this triggered an annoying warning but it's an extra sanity check */
|
|
}
|
|
}
|
|
fp = fopen(filename, "r");
|
|
if (fp == NULL)
|
|
{
|
|
fprintf(stderr, "couldn't open data file\n");
|
|
exit(1);
|
|
}
|
|
|
|
/*
|
|
* i now starts out at 1 due to the way the padded file is
|
|
*/
|
|
i = 1;
|
|
while (getdelim(&buf, &len, '\0', fp) != -1)
|
|
{
|
|
printf("<%zu>\n%s\n", i, *buf=='\a'?buf+1:buf);
|
|
++i;
|
|
}
|
|
|
|
/*
|
|
* the next test was necessary earlier on but is not needed now. I keep it
|
|
* here to document my procedure.
|
|
*/
|
|
|
|
#if 0
|
|
/*
|
|
* clear out buf first
|
|
*/
|
|
free(buf);
|
|
buf = NULL;
|
|
/*
|
|
* reset EOF
|
|
*/
|
|
rewind(fp);
|
|
|
|
/*
|
|
* now we have to verify that string 2 is what we see from the output (34).
|
|
*
|
|
* Obviously (if you look at data.src) the file has changed some since this byte
|
|
* check.
|
|
*/
|
|
if (getdelim(&buf, &len, EOF, fp) != -1)
|
|
{
|
|
/*
|
|
* we want to print the string that starts out at 34:
|
|
*/
|
|
printf("\n34: %s\n", buf+34);
|
|
}
|
|
|
|
free(buf);
|
|
buf = NULL;
|
|
#endif
|
|
|
|
fclose(fp);
|
|
fp = NULL;
|
|
}
|