如何用C语言实现post一个地址,并记录post数据

http://xxxx.xxx

idcode
actcode

data

./log idcode actcode data
post http://xxxx.xxxx
if(result=ok){
read logs from '/Skoo/Box/log/log.txt' one by one
post it
if(result=ok){
delete it
}
}
else{
white it to 'log.txt'
}

上面是伪代码,我想知道如何实现post,最好有代码。
C语言和shell吧尽量,谢谢

C可以用curl

 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>

#define POSTURL    "http://www.xiami.com/member/login"
#define POSTFIELDS "email=myemail@163.com&password=mypassword&autologin=1&submit=登 录&type="
#define FILENAME   "curlposttest.log"

size_t write_data(void* buffer,size_t size,size_t nmemb,void *stream)
{
    FILE *fptr = (FILE*)stream;
    fwrite(buffer,size,nmemb,fptr);
    return size*nmemb;
}

int main(int argc,char *argv[])
{
    CURL *curl;
    CURLcode res;
    FILE* fptr;
    struct curl_slist *http_header = NULL;

    if ((fptr = fopen(FILENAME,"w")) == NULL)
    {
        fprintf(stderr,"fopen file error:%s\n",FILENAME);
        return -1;
    }

    curl = curl_easy_init();
    if (!curl)
    {
        fprintf(stderr,"curl init failed\n");
        return -1;
    }

    curl_easy_setopt(curl,CURLOPT_URL,POSTURL); //url地址
    curl_easy_setopt(curl,CURLOPT_POSTFIELDS,POSTFIELDS); //post参数
    curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,write_data); //对返回的数据进行操作的函数地址
    curl_easy_setopt(curl,CURLOPT_WRITEDATA,fptr); //这是write_data的第四个参数值
    curl_easy_setopt(curl,CURLOPT_POST,1); //设置问非0表示本次操作为post
    curl_easy_setopt(curl,CURLOPT_VERBOSE,1); //打印调试信息
    curl_easy_setopt(curl,CURLOPT_HEADER,1); //将响应头信息和相应体一起传给write_data
    curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1); //设置为非0,响应头信息location
    curl_easy_setopt(curl,CURLOPT_COOKIEFILE,"/Users/zhu/CProjects/curlposttest.cookie");

    res = curl_easy_perform(curl);

    if (res != CURLE_OK)
    {
        switch(res)
        {
            case CURLE_UNSUPPORTED_PROTOCOL:
                fprintf(stderr,"不支持的协议,由URL的头部指定\n");
            case CURLE_COULDNT_CONNECT:
                fprintf(stderr,"不能连接到remote主机或者代理\n");
            case CURLE_HTTP_RETURNED_ERROR:
                fprintf(stderr,"http返回错误\n");
            case CURLE_READ_ERROR:
                fprintf(stderr,"读本地文件错误\n");
            default:
                fprintf(stderr,"返回值:%d\n",res);
        }
        return -1;
    }

    curl_easy_cleanup(curl);
}

使用平台提供的网络API,比如Windows有wininet
或者用socket,Windows下有winsock2,Linux下面也有socket

可以库 libcurl,支持Windows,Unix,Linux等,线程安全,易于使用。
最新版本http://curl.haxx.se/download/curl-7.43.0.tar.gz。
代码参考@oyljerry