这是我的代码:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main(int arge, char *argv[])
{
FILE *f1;
char ch,*fn="~/lyrics/";
strcat(fn,argv[1]);
strcat(fn,".txt");
if( (f1 = fopen(fn,"r"))==NULL )
{
printf("\nWrong filename\n%s not found",argv[1]);
return;
}
while((ch=getw(f1))!=EOF)
{
printf("%c",ch);
}
}
我使用它编译它gcc -g -o file file.c
并且编译器没有给出错误消息。但是当我运行它时,我收到错误消息:
Segmentation fault (core dumped)
Bad permissions for mapped region at address 0x8048659 at 0x402C36B: strcat
(in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) by 0x80484D6: main (lyrics.c:9)
谁能帮帮我吗?