Miscellany
public text v1 · immutable#include <stdio.h>
#include <assert.h>
main(int argc, char *argv[])
{
FILE *f;
int rv, v[4];
f = fopen(argv[1], "r+");
assert(f != NULL);
rv = fseek(f, 16, SEEK_SET);
assert (rv != -1);
printf("%ld\n", ftell(f));
rv = fread(v, sizeof v, 1, f);
assert (rv != -1);
printf("%ld\n", ftell(f));
v[0] = 0;
rv = fwrite(&v[0], sizeof v[0], 1, f);
printf("%ld\n", ftell(f));
}
--------------------------------------
dd if=/dev/zero of=bar bs=1024 count=1
./a.out bar