喲!如何將char []中的幾個字符複製到C中的char *?
我想從char []複製一些字符到char *。我只想從索引6到字符(消息長度-9)。
也許代碼示例將解釋我的問題更多:
char buffer[512] = "GET /testfile.htm HTTP/1.0";
char* filename; // I want *filename to hold only "/testfile.htm"
msgLen = recv(connecting_socket, buffer, 512, 0);
strncpy(filename, buffer+5, msgLen-9);
任何反應會很多幫助!
我想你的意思是「strncpy()函數(文件名......」,而不是「strncpy()函數(文件」 文件是不是在你的代碼中聲明的變量 – abelenky 2009-01-07 19:12:05
這是正確的感謝。。。) – petsson 2009-01-07 19:30:49