这是我的代码:
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <stdio.h>
#include <curl/curl.h>
using namespace std;
int main ()
{
ifstream llfile;
llfile.open("C:/log.txt");
if(!llfile.is_open()){
exit(EXIT_FAILURE);
}
string word;
llfile >> word;
llfile.close();
string url = "http://example/auth.php?ll=" + word;
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, url);
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编译时这是我的错误:
的main.cpp | 29 |警告:不能通过非POD的对象类型
'struct std::string'通过'...'; call将在运行时中止
我正在尝试使用libcurl上传文件,但似乎它没有验证与我的服务器的连接.我试过使用ftp://username:password@example.com/但无济于事.这是我的代码:
#include <stdio.h>
#include <string.h>
#include <curl/curl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#ifdef WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#define LOCAL_FILE "C:/myfile.txt"
#define UPLOAD_FILE_AS "file.txt"
#define REMOTE_URL "ftp://example.com/" UPLOAD_FILE_AS
#define RENAME_FILE_TO "file.txt"
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
{
curl_off_t nread;
size_t retcode = fread(ptr, size, nmemb, (FILE *) stream);
nread = (curl_off_t) retcode;
fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T " bytes from filen", nread);
return retcode;
}
int main(void) …Run Code Online (Sandbox Code Playgroud) 此代码应等待.help在聊天中输入,然后发送消息说"Help text.".什么都没发生.
package testplugin.HelpMe;
import java.util.logging.Logger;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.player.PlayerChatEvent;
public class HelpMe extends JavaPlugin implements {
Logger log;
public void onEnable(){
log = this.getLogger();
log.info("Your plugin has been enabled!");
}
public void onDisable(){
log.info("Your plugin has been disabled.");
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return false;
}
public void onChat(PlayerChatEvent event) {
if (event.getMessage().startsWith(".help"))
{
event.getPlayer().sendMessage("Help text.");
event.setCancelled(true);
}
}
}
Run Code Online (Sandbox Code Playgroud)