我有问题将一些值插入数据库.数据库名称是用户,表是英雄.我正在为了学习而开发一些mmorpg游戏.
这是有效的mysql代码
INSERT INTO heroes (HeroID,Strenght, Dexterity, Vitality, Wisdom, Inteligence, Luck, Name, Level, XP) VALUES (NULL, 17, 13, 17, 15, 9, 8, 'works', 4, 3750);
Run Code Online (Sandbox Code Playgroud)
但是当我从c ++通过mysql ++尝试时,我得到了错误.
码:
#include <mysql++/mysql++.h>
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// Connect to the database.
mysqlpp::Connection conn(false);
if (conn.connect("users", "localhost",
"root", "toor"))
{
mysqlpp::Query query = conn.query();
query << "INSERT INTO heroes" <<
"VALUES (NULL, 17, 13, 17, 15, 9, 8, doSomething,3, 3260);";
query.execute();
if (mysqlpp::StoreQueryResult res = query.store()) …Run Code Online (Sandbox Code Playgroud) 我有ComboBox,其中包含分辨率的值.从800x600开始到1920x1080.我试图从分辨率模式中取出(这个)x(和这个).我可以从ComboBox中获取选定的值但是我没有达到我用字符串计划的内容.
comboBox->GetSelectedValue() // i get value here
std::stringstream buffer;
buffer << comboBoxValue;
std::string myBufferResolution = buffer.str();
size_t Position1 = 0;
size_t Position2;
Position2 = myBufferResolution.find("x", Position1);
myBufferResolution.substr(Position1, (Position2-Position1));
Position1 = Position2+1;
std::cout << "Selected resolution is: " << myBufferResolution << std::endl;
Run Code Online (Sandbox Code Playgroud)
std :: cout只打印选定的值但是我想要的,如果我cout comboBox-> GetSelectedValue()我会得到.
如何从800x600,1024x768等获取值?因为我做错了什么