可以帮我找下错误吗
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
void lowercase_remove_punct(char *original_string, char *processed_string) {
int i1, i2;
char c;
for (i1 = 0, i2 = 0; i1 < strlen(original_string); i1++) {
c = original_string[i1];
if ((c >= 'A') && (c <= 'Z'))
processed_string[i2++] = original_string[i1] - 'A' + 'a';
if (((c >= 'a') && (c <= 'z')) || (c == '\''))
processed_string[i2++] = original_string[i1];
}
processed_string[i2] = '\0';
}
void BubbleSort(int* a, char** b, int length) {
if (length > 1) {
int j, k, t;
char* temp;
temp = (char*) malloc(20 * sizeof (char));
while (1) {
int flag = 0;
j = 0;
for (k = j + 1; k < length; j++, k++) {
if (a[j] > a[k]) {
t = a[j];
strcpy(temp, b[j]);
a[j] = a[k];
strcpy(b[j], b[k]);
a[k] = t;
strcpy(b[k], temp);
flag = 1;
}
}
if (flag == 0) break;
}
}
}
int main(int argc, char* argv[]) {
FILE* in_file;
in_file = fopen("textfile.txt", "r");
char* in_string;
char* out_string;
char** store_string;
int* count_array;
int end_of_file;
store_string = (char**) malloc(500 * sizeof (char*));
count_array = (int*) malloc(500 * sizeof (int));
if (in_file == NULL) {
printf("file open fail");
} else {
int num = -1;
do {
in_string = (char*) malloc(20 * sizeof (char));
out_string = (char*) malloc(20 * sizeof (char));
end_of_file = fscanf(in_file, "%s", in_string);
if (end_of_file != EOF) {
num++;
lowercase_remove_punct(in_string, out_string);
if (out_string[0] == '\0') {
num--;
continue;
}
store_string[num] = (char*) malloc(20 * sizeof (char));
int i;
int flag = 0;
for (i = 0; i < num; i++) {
if (strcmp(store_string[i], out_string) == 0) {
flag = 1;
count_array[i]++;
}
}
if (flag != 1) {
strcpy(store_string[num], out_string);
count_array[num] = 1;
} else {
num--;
}
}
} while (end_of_file != EOF);
fclose(in_file);
printf("All the words appeared without repeatation:\n");
int p;
for(p=0;p<=num;p++){
printf("%s ", store_string[p]);
}
printf("\n");
BubbleSort(count_array, store_string, num + 1);
int k1, k2;
printf("20 least words:\n");
for (k1 = 0; k1 < 20; k1++) {
printf("%s %d\n", store_string[k1], count_array[k1]);
}
printf("20 most words:\n");
for (k2 = num; k2 > num - 20; k2--) {
printf("%s %d\n", store_string[k2], count_array[k2]);
}
}
return 0;
}
20 least words:
whatthefuck 1
bluescreen 1
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
(null) 0
20 most words:
bluescreen 1
whatthefuck 1