- if ((fp = fopen(filename, "r")) == NULL) {
- fprintf(stderr,"Cannot open %s\n", filename);
- exit(1);
- }
+ if ((fp = fopen(filename, "r")) == NULL)
+ fatal("Cannot open %s\n", filename);
+
- if ((fp = fopen(filename, "r")) == NULL) {
- fprintf(stderr,"Cannot open %s\n", filename);
- exit(1);
- }
+ if ((fp = fopen(filename, "r")) == NULL)
+ fatal("Cannot open %s\n", filename);
+
for (i = 0; i < no_of_words; i++) {
fscanf(fp, "%s", buf); /* store word in temporary buffer */
a[i].word = strdup(buf);
for (i = 0; i < no_of_words; i++) {
fscanf(fp, "%s", buf); /* store word in temporary buffer */
a[i].word = strdup(buf);
fscanf(fp, "%d", &a[i].freq);
a[i].word_len = strlen(a[i].word);
a[i].cum_freq = temp_cfreq;
fscanf(fp, "%d", &a[i].freq);
a[i].word_len = strlen(a[i].word);
a[i].cum_freq = temp_cfreq;
- if ((fp = fopen(filename, "r")) == NULL) {
- fprintf(stderr,"Cannot open %s\n", filename);
- exit(1);
- }
+ if ((fp = fopen(filename, "r")) == NULL)
+ fatal("Cannot open %s\n", filename);
+
for (i = 0; i < no_of_docs; i++) {
fscanf(fp, "%d", &d[i].doc_len);
fscanf(fp, "%d", &d[i].doc_freq);
for (i = 0; i < no_of_docs; i++) {
fscanf(fp, "%d", &d[i].doc_len);
fscanf(fp, "%d", &d[i].doc_freq);