Exemplo n.º 1
0
Arquivo: main.c Projeto: sugite/Util
int main(int argc, char **argv)
{
	char		buf[WORD_LEN_MAX];
	FILE		*fp;
	if(argc == 1){
		fp = stdin;
	}else{
		fp = fopen(argv[1], "r");
		if(fp == NULL){
			fprintf(stderr, "%s:%s can not open.\n", argv[0],argv[1]);
			exit(1);
		}
	}


	word_initialize();

	while(get_word(buf, WORD_LEN_MAX, fp) != EOF){
		add_word(buf);
	}

	dump_word(stdout);

	word_finalize();

	return 0;
}
Exemplo n.º 2
0
int main(int argc, char **argv){
	char buf[WORD_LEN_MAX];
	FILE *fp;

	if(argc ==1){
		fp = stdin;
	}else{
		fp = fopen(argv[1], "r");
		if(fp == NULL){
			fprintf(stderr, "%s:%s can not open.\n",argv[0],argv[1]);
			exit(1);
		}
	}
	/*initialize word manage*/
	word_initialize();
	/*read the file, meantime,add the word*/
	while(get_word(buf, WORD_LEN_MAX, fp)!= EOF){
		add_word(buf);
	}
	/*print times of the word*/
	dump_word(stdout);
	/*end the word manage*/
	word_finalize();

	return 0;
}
Exemplo n.º 3
0
int main(int argc, char	**argv){
	char buf[WORD_LEN_MAX];
	FILE *file;
	if(argc == 1){
		file = stdin;
	}else{
		file =fopen(argv[1], "r");
		if(file == NULL){
			fprintf(stderr,"%s %s can not open",argv[0],argv[1]);
			exit(1);
		}
	}
	/* 单词管理模块初始化*/ 
	word_initialize();
	
	while(getWord(buf, WORD_LEN_MAX, file) != EOF){
		add_word(buf);
	}
	
	dump_word(stdout);
	
	word_finalize();
	
	return 0;
}