请教Linux下C编程问题:段错误,fseek

helenm
请教Linux下C编程问题:段错误,fseek

各位大侠,初学linux下c编程,困难重重,还请赐教啊。先谢谢了啊,以下是调试过程:
43        if((connectfd=accept(listenfd,(struct sockaddr *)&client,&sin_size))==-1){
(gdb)
47       process_cli(connectfd,client);
(gdb)

Breakpoint 2, process_cli (connectfd=6, client=
      {sin_family = 2, sin_port = 9603, sin_addr = {s_addr = 1728161984}, sin_zero = "瞱/022繲/006/215?"}) at zfpserverT.c:55
55        printf("You got a connection from %s.",inet_ntoa(client.sin_addr));
(gdb)
56        num=recv(connectfd,file_name,SEND_BUFFER_SIZE,0);
(gdb)
57        if(num==0){
(gdb)
62        file_name[num-1]='/0';
(gdb)
63        printf("The filename the client needs is %s./n",file_name);
(gdb)
You got a connection from 192.168.1.103.The filename the client needs is 1.mp3.
64        switch(file_name[0])
(gdb)
79                {sourceFile=fopen("/temp/1.mp3","r");
(gdb)
80                 break;
(gdb)
83         leftToSend=sizeof(sourceFile);
(gdb)
84         fseek(sourceFile,0L,SEEK_SET);
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x42069267 in fseek () from /lib/tls/libc.so.6
(gdb) where
#0  0x42069267 in fseek () from /lib/tls/libc.so.6
#1  0x080488b6 in process_cli (connectfd=6, client=
      {sin_family = 2, sin_port = 9603, sin_addr = {s_addr = 1728161984}, sin_zero = "瞱/022繲/006/215?"}) at zfpserverT.c:84
#2  0x080487b9 in main () at zfpserverT.c:47
#3  0x42015574 in __libc_start_main () from /lib/tls/libc.so.6

HelpMyself
"sourceFile=fopen("/temp/1.mp3","r");"
does the 1.mp3 exist or it can be open?
上一篇:在线程中调用exit会有些什么? 下一篇:下面没有链接了