我已经评论了所有我认为给我带来错误的代码,但我仍然得到它。这是我的代码:
int main(int argc, char **argv) {
// argc is the number of command line arguments, in our case there are two
// argv is an array of pointers, a[0] is the program name, a[1] will be sourcewav
// and a[2] should be destwav
FILE * source_file;
FILE * destination_file = fopen(argv[2], "w") ; // create destwav file
if (argc != 3) {
printf("Usage: requires two parameters: sourcewav and destwav");
exit(1);
}
//source_file = fopen(argv[1], "r+");
if (!source_file) { // pointer is null, file can't be opened
printf("Usage: %s sourcewav file cannot be opened\n", argv[0]);
exit(1);
}
printf("1");
remvocals(source_file, destination_file); // remove vocals
int closed_properly = fclose(source_file); // has source_file successfully closed?
if (closed_properly != 0) {
printf("Usage: %s sourcewav was not closed properly\n", argv[0]);
exit(1);
}
fclose(destination_file);
return 0;
}
最佳答案
您检查源文件
而不对其进行初始化。另外,remvocals 有什么作用?
关于c - 查找 C 中的段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28165687/