我正在为 POS 机编写此代码
我将来自网络链接的返回数据设置为“坏”,以便我可以测试它是否真的有效。但是当我将结果与字符串“坏”进行比较时,它总是说它们不相等。当我将结果打印到屏幕上时购买,它显示两个结果都不好。
拜托我需要你的帮忙。下面的代码
void checklogin(void) {
CURL *curl;
CURLcode res;
long timeout = 30;
char buffer[50000];
//Initializing the CURL module
curl = curl_easy_init();
if(curl){
//Tell libcurl the URL
curl_easy_setopt(curl,CURLOPT_URL, "http://website.org/login.php");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "username=su&password=ch");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, myfunc);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); //tell curl to output its progress
res = curl_easy_perform(curl);
CTOS_LCDTClearDisplay();
char mai[30];
char mai2[30];
char *serverresponse = "bad";
sprintf(mai2, "%s" , serverresponse);
sprintf(mai, "%s" , buffer);
if(mai2 == mai){
CTOS_LCDTPrint("Invalid username");
CTOS_KBDGet(&key);
}else{
//loginname = buffer;
//mainusername = username;
CTOS_LCDTPrintXY(1, 1, "Login Success");
CTOS_LCDTPrintXY(1, 2, "Welcome");
CTOS_KBDGet(&key);
}
}
}