我写了一个简单的控制台应用程序的代码。编译时,编译成功,但是遇到代码块ID时,会给出一些错误。我将共享代码和错误图像以及编译器设置图片
#include <iostream>
#include <string>
#include <cstring>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include "sqlite3.h"
#include "tinyxml2.h"
#include <chrono>
#include "restclient-cpp/restclient.h"
#include "restclient-cpp/connection.h"
using namespace std;
using namespace tinyxml2;
static int callback(void* data, int argc, char** argv, char** azColName)
{
string str, str1, file_name;
unsigned __int64 ms = chrono::duration_cast< chrono::milliseconds >(chrono::system_clock::now().time_since_epoch()).count();
str = to_string(ms);
str1 = ".xml";
file_name = str.append(str1);
cout << "File name is - " << file_name << endl;
int filename_len = file_name.length();
char filename[filename_len];
strcpy(filename, file_name.c_str());
int i;
for (i = 0; i < argc; i++) {
printf("%s = %s \n", azColName[i], argv[i]);
//Sleep(30);
XMLDocument xmlDoc;
XMLNode * pRoot = xmlDoc.NewElement("Root");
xmlDoc.InsertFirstChild(pRoot);
for(int j=0; j<argc; j++){
XMLElement * pElement = xmlDoc.NewElement(azColName[j]);
pElement->SetText(argv[j]);
pRoot->InsertEndChild(pElement);
xmlDoc.SaveFile(filename);
//File Data Parse
}
string str, temp, str2;
ifstream fin;
fin.open(filename);
if(!fin){
cout << " File is not open" << endl;
}else{
cout << " File is open success" << endl;
while(fin){
getline(fin, temp);
//cout << temp << endl;
str = temp;
str2= str2+str;
}
cout <<" File xml Data to send api = " << str2 << endl;
fin.close();
}
RestClient::Response ob = RestClient::get("www.google.com");
if(ob.code == 200){
cout << "Connection Establish" << endl;
}else{
cout << "Retry more time" << endl;
}
printf("\n");
}
return 0;
}
我还将上传错误代码的图片 error message [链接器设置][2] 但是我的代码没有任何错误。为什么给它
int main()
{
sqlite3* DB;
char* messagesError;
int exit = sqlite3_open("newinformation.db", &DB);
if (exit) {
cerr << "Error open DB " << sqlite3_errmsg(DB) << endl;
return (-1);
}
else
cout << "Opened Database Successfully!" << endl;
string query = "SELECT id,amount,businessdate,checknumber,localdata,localtime,requestcode,revenuecenter,terminalid,track2,TransactionEmployee,security,refid FROM SOCKETDATA ;";
exit = sqlite3_exec(DB, query.c_str(), callback, NULL, &messagesError);
sqlite3_close(DB);
return (0);
}