下面是完整的代码示例:

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <curl/curl.h>
 
int main()
{
    CURL *curl;
    CURLcode res;
    struct curl_slist *headerlist = NULL;
    
    curl_global_init(CURL_GLOBAL_DEFAULT);
    curl = curl_easy_init();
    
    if(curl)
    {
        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
        curl_easy_setopt(curl, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
        curl_easy_setopt(curl, CURLOPT_URL, "sftp://192.168.2.15:22/test02/folder");
        curl_easy_setopt(curl, CURLOPT_USERPWD, "sftpuser:123");
        
        headerlist = curl_slist_append(headerlist, "mkdir 20230510");
        curl_easy_setopt(curl, CURLOPT_POSTQUOTE, headerlist);
        
        res = curl_easy_perform(curl);
        if(res != CURLE_OK)
        {
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
        }
        
        curl_easy_cleanup(curl);
        curl_slist_free_all(headerlist);
    }
    
    curl_global_cleanup();
    return 0;
}

libcurl sftp 新建文件夹_ios