我一直在寻找可以与Windows/Win32上的串行设备通信的Java API,但我检查过的许多API要么是用于Linux,要么过时,要么就是批评不好的人.
有人可以向我推荐一个他们已经尝试或知道的在Windows XP上易于实现吗?
我有一些旧的C代码,我想与一些C++代码结合起来.
以前的C代码包含以下内容:
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "mysql.h"
Run Code Online (Sandbox Code Playgroud)
现在我试图让它像这样使用带有iostream的C++:
#include <windows.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include "mysql.h"
Run Code Online (Sandbox Code Playgroud)
但是在编译时我不断收到以下链接器错误:
[链接器错误]对`std :: string :: size()const'的未定义引用
[链接器错误]对`std :: string :: operator [](unsigned int)const'的未定义引用
[链接器错误]对`std :: string :: operator [](unsigned int)const'的未定义引用
[链接器错误]对`std :: string :: operator [](unsigned int)const'的未定义引用
[链接器错误]对`std :: ios_base :: Init :: Init()'的未定义引用
[链接器错误]对`std :: ios_base :: Init :: ~Init()'的未定义引用
ld返回1退出状态
我该如何解决这个问题?
编辑:我的编译器是Dev-C++ 4.9.9.2
我有一个char数组缓冲区,我用它来存储用户将逐个输入的字符.我下面的代码有效,但有一些我无法弄清楚的故障:
有人可以向我解释发生了什么,也许我可以解决这个问题?谢谢.
char Buffer[8]; //holds the byte stream
int i=0;
if (/* user input event has occurred */)
{
Buffer[i] = charInput;
i++;
// Display a response to input
printf("Buffer is %s!\n", Buffer);
}
Run Code Online (Sandbox Code Playgroud)
输出:
tagBuffer is 1??w! tagBuffer is 12?w! tagBuffer is 123w! tagBuffer is 1234! tagBuffer is 12345! tagBuffer is 123456=! tagBuffer is 1234567! tagBuffer is 12345678!
tagBuffer是123456789!
有没有人知道用于在WIN32环境中控制RS-232设备的优秀Java API?我试过RXTX,但他们不支持RS232,只支持RS-485.
我知道在很多异步通信中,数据包从一个起始位开始.
但是起始位只是1或0.如何区分起始位和结束位与最后一个数据包?
防爆.如果我选择我的起始位为0而我的结束位为1.并且我收到0(数据流A)1 0(数据流B)1,有什么可以阻止我假设有一个包含数据流的数据流"(数据流A)1 0(数据流B)"的相同内容是什么?
有一个启动BYTE,然后检查数据流的位组合是不是更方便?这将减少开始/结束位之间混淆的可能性.
我在mysql中创建一个新表,我正在尝试向其中一个字段添加外键约束.
CREATE TABLE `onlineorder` ( `receiptid` varchar(10) NOT NULL default '', `delivereddate` date default NULL, `cid` int(10) NOT NULL, `card#` int(10) default NULL, `expire` date default NULL, PRIMARY KEY (`receiptid`), FOREIGN KEY (receiptid) REFERENCES purchase ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
但是,在创建它之后,我进入phpMyAdmin并导出表.似乎外键约束已经消失.
CREATE TABLE `onlineorder` ( `receiptid` varchar(10) NOT NULL default '', `delivereddate` date default NULL, `cid` int(10) NOT NULL, `card#` int(10) default NULL, `expire` date default NULL, PRIMARY KEY (`receiptid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
phpMyAdmin是摆脱外键还是我在这里做错了什么?
我正在使用 MySQL C API 来查询数据库,并将结果存储在 MYSQL_ROW 类型中。我可以将结果打印到控制台
printf("%s", row[0]);
Run Code Online (Sandbox Code Playgroud)
但是,根据 MySQL C API 文档,我不能将它们用作以 null 结尾的字符串。
在功能概述的底部,他们说我可以使用mysql_store_result()或来“提取”信息mysql_use_result()。但是,我仍然对这是如何完成的感到困惑。
理想情况下,我想将结果用作字符串,以便我可以执行类似的操作strcmp,但否则我肯定需要以某种方式将这些信息与这两个函数一起使用。
有人可以向我展示如何执行此操作的示例吗?
我有两个表,我想加入,但我收到MySQL的错误
Table: books
bookTagNum ShelfTagNum
book1 1
book2 2
book3 2
Table: shelf
shelfNum shelfTagNum
1 shelf1
2 shelf2
Run Code Online (Sandbox Code Playgroud)
我希望我的结果是:
bookTagNum ShelfTagNum shelfNum
book1 shelf1 1
book2 shelf2 2
book3 shelf2 2
Run Code Online (Sandbox Code Playgroud)
但相反,我也得到了额外的结果:
book1 shelf2 2
Run Code Online (Sandbox Code Playgroud)
我认为我的查询是在进行交叉产品而不是连接:
SELECT `books`.`bookTagNum` , `books`.`shelfNum` , `shelf`.`shelfTagNum` , `books`.`title`
FROM books, shelf
where `books`.`shelfNum`=`books`.`shelfNum`
ORDER BY `shelf`.`shelfTagNum` ASC
LIMIT 0 , 30
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
这一行:
strcat(query,*it);
Run Code Online (Sandbox Code Playgroud)
(*it字符串的迭代器在哪里)
继续给我这个错误:
没有匹配函数来调用``strcat(char [200],const std :: basic_string,std :: allocator>&)`'
我想这是因为strcat花费一段char*时间*it是一个字符串.如何将其从字符串转换char*为使其适用strcat()?
我试过strcat(query,(*it).c_str())但只是给了我一个运行时错误.
编辑:抱歉,它应该转换为 const char*
c ×3
c++ ×3
java ×2
mysql ×2
serial-port ×2
string ×2
windows ×2
asynchronous ×1
bit ×1
char ×1
cstring ×1
foreign-keys ×1
iostream ×1
linker ×1
phpmyadmin ×1
set ×1
sql ×1
stdset ×1
stl ×1