char str1[4096];
snprintf(str1, sizeof(str1), ":%s", sock_ntop((SA* )&cliaddr, clilen));
我的目的就是想把sock_ntop轉換的cliaddr ipv4地址前面加個冒號,然後復制到str1中,使最後的格式為str1 = ":127.0.0.1"
但是,這個函數調用總是出錯,錯誤代碼如下:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7a60a03 in _IO_vfprintf_internal (s=s@entry=0x7fffffffbb30, format=,
format@entry=0x401f18 ":%s", ap=ap@entry=0x7fffffffbc98) at vfprintf.c:1661
1661 vfprintf.c: No such file or directory.
整個程序代碼好多,我就不貼了.
sock_ntop((SA* )&cliaddr, clilen)
應該是它調用出錯了吧。先看它的返回值