当前位置: 技术问答>linux和unix
怎样用C语言获得百度MP3中的歌名?
来源: 互联网 发布时间:2016-12-13
本文导语: 我用了如下方式,但出来的中文全是乱码,失败了…… #include #include #include #include #include int main(int argc, char* argv[]) { char webname[] = "GETn"; int s = socket(AF_INET,SOCK_STREAM,0); struct so...
我用了如下方式,但出来的中文全是乱码,失败了……
#include
#include
#include
#include
#include
int main(int argc, char* argv[])
{
char webname[] = "GETn";
int s = socket(AF_INET,SOCK_STREAM,0);
struct sockaddr_in saddr;
saddr.sin_family = AF_INET;
saddr.sin_port = htons(80);
saddr.sin_addr.s_addr = inet_addr("119.75.217.56");
int len = sizeof(saddr);
int err = connect(s,(struct sockaddr*)&saddr,len);
char buf[1024*10] = {};
int num = send(s,webname,sizeof(webname),0);
int recvlen = recv(s,buf,sizeof(buf),0);
puts(buf);
printf("len = %dn",recvlen);
}
|
编码转换,基本上从网页中获取的都UTF-8的.