File: makekanjstroke.c

package info (click to toggle)
xjdic 24-12
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 940 kB
  • sloc: ansic: 18,786; makefile: 191; sh: 55
file content (33 lines) | stat: -rw-r--r-- 583 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

FILE *fi,*fo,*fopen();
unsigned char instr[1000],*ptr;
int i;

int main()
{
	fo = fopen("kanjstroke","w");
	if (fo == NULL)
	{
		printf("Unable to open output file: kanjstroke\n");
		exit(1);
	}
	fi = fopen("kanjidic","r");
	if (fi == NULL)
	{
		printf("Unable to open input file: kanjidic\n");
		exit(1);
	}
	while(!feof(fi))
	{
		fgets(instr,999,fi);
		if (feof(fi)) break;
		if (instr[0] < 127) continue;
		ptr = strstr(instr," S");
		i = atoi(ptr+2);
		fprintf(fo,"%c%c%c\n",instr[0],instr[1],i+'0');
	}
	fclose(fo);
}