我现在正在为fpga上的microblaze编写交流程序,我现在想检查一下我是否收到了消息,但是strncmp和strcmp不工作的唯一方法就是这样:
char*as=malloc(sizeof(int));
as=p->payload;
if (*(as)=='o') {//first letter o
if (*(as+1)=='k') {//second letter
Run Code Online (Sandbox Code Playgroud)
但是,一旦我处理较长的文本,这将很难,所以任何好方法?我用这种格式试了strncmp:
if (strncmp(as,"ok",2)==0) //didnt work even changing 0 to 1 it just doesnt detectct it
Run Code Online (Sandbox Code Playgroud)