我想使用curl/curl.h來清理URL輸入,但是當我編譯時出現以下錯誤:「error:expected declaration specifiers or'...' 'X」。它被綁定到代碼行:「char * curl_easy_escape(CURL * curl,char * Buffer,x);」但我不確定問題是什麼。C curl/curl.h錯誤
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <openssl/md5.h>
#include <curl/curl.h>
main(int argc, char **argv, char **envp) {
printf("Content-type: text/html\n\n");
char *qPtr;
FILE *fPtr;
unsigned char digest[MD5_DIGEST_LENGTH];
int i;
char mdString[33];
int x = 0;
if(qPtr = getenv("QUERY_STRING")) {
char Buffer[256];
char *Token;
char username[80], password[80], email[80];
strncpy(Buffer, qPtr, 255); //copy Env variable "QUERY_STRING" into qPtr pointer
//clean up URL
char *curl_easy_escape(CURL * curl, char *Buffer, x);
Token = strtok(Buffer, "&"); //get first query
sscanf(Token, "username=%s", username); //gets value of username field input
Token = strtok(NULL, "&"); //get second query
sscanf(Token, "password=%s", password); //gets value of password field input
//Execute MD5 library on password string
MD5((unsigned char *)&password, strlen(password), (unsigned char*)&digest);
for(i = 0; i < 16; i++) {
sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]);
} //end MD5
Token = strtok(NULL, "&"); //get third query
sscanf(Token, "email=%s", email); //gets value of email field input
//write username, password and email to file
fPtr = fopen("users.txt", "a+");
fprintf(fPtr, "%s=", username);
fprintf(fPtr, "%s=", mdString);
fprintf(fPtr, "%s\n", email);
fclose(fPtr);
} else { printf("<p>Error: did not get a QUERY_STRING variable."); }
}