|
可以说是有点恶心的程序了!不过还可以查查五笔,
本不怕丑的决心放出来:
假定是用fcitx 的那个wbx.mb文件,试了一下98的编码改了好多,都不懂打字了 :p ,
如果有需要大家把它弄得漂亮一些!
- #ifdef HAVE_CONFIG_H
- #include <config.h>
- #endif
- #include <stdio.h>
- #include <stdlib.h>
- void usage(void) {
- printf("用法: 程序名 你要查的字或词\n");
- }
- int findword(const char *a, const char *b) {
- int i, j;
- int equal = 1;
- j = strlen(a) - 2;
- for (i = strlen(b) - 1; i >= 0; i--) {
- if (b[i] != a[j]) {
- equal = 0;
- return equal;
- }
- j--;
- }
- if (a[j] < 0)
- equal = 0;
- return equal;
- }
- void findcode(const FILE *p, const char *word) {
- char strline[64];
- char *str;
- rewind(p);
- while (!feof(p)) {
- fgets(strline, 64, p);
- if (findword(strline, word))
- puts(strline);
- }
- }
- int main(int argc, char *argv[])
- {
- char filename[]="/usr/share/fcitx/wbx.mb";
- FILE *fp;
- int i;
- if (argc != 2) {
- usage();
- exit(0);
- }
- fp = fopen(filename, "r");
- if (!fp) {
- fprintf(stderr, "打开 wbx.mb 文件错误!\n");
- exit(1);
- }
- findcode(fp, argv[1]);
- return EXIT_SUCCESS;
- }
复制代码 |
|