これが私の main() のコードです
int main(int argc, char **argv) {
if (argc != 3) {
puts("Invalid number of args in the input. Sorry.");
return 0;
}
if (doesItExist(argv[2]) == 0) {
return 0;
}
FILE *fpoint;
char yesorno[2];
tail = (WordN) malloc(sizeof(struct WordNode));
tail->word = "";
tail->first = (FileN) malloc(sizeof(struct FileNode));
(tail->first)->freq = -1;
ftw(argv[2], tokeForMe, 1);
/**
fpoint = fopen(argv[1], "r");
if(fpoint != NULL) { // file exists give user option to overwrite or rename
getInput("Do you want to overwrite the file? Enter only either Y or N nothing else\n", yesorno, 2);
if(yesorno[0] == 'N' || yesorno[0] == 'n') {
puts("All right. Not going to proceed with the program");
return 0;
}
else if(yesorno[0] != 'Y' && yesorno[0] != 'y') {
puts("You inputted some other character, try again \n");
getInput("Do you want to overwrite the file? Enter Y or N. Do not enter anything other than 1 Y or 1 N \n", yesorno, 2);
}
}
fclose(fpoint);
**/
FILE *index;
index = fopen(argv[1], "w");
//puts("here");
writeToIndex(index, tail->next); //tail is pointing to the first word node
puts("there");
if (doesItExist(argv[1]) == 0) {
return 0;
}
fclose(index);
TailTerminate();
return 0;
}
ユーザーが argv[1] で指定されたファイルを上書きするかどうかを調べるために argv[1] を読み取るファイル ポインターを作成するときに、その部分のコメントを解除すると、コード セグメント エラーが発生します。
プログラム自体は、ファイルのディレクトリから一種のインデクサーを作成し、それを出力する単なるプログラムです。ディレクトリ パスは argv[2] で指定され、インデックスを出力するパスは argv[1] で指定されます。
誰かがこれで私を助けることができますか? プログラムの残りの部分 (Tail ノードなど) は、プログラムに出現する単語と頻度の一種のリストを作成するだけです。