本文介绍了从整数STRCMP指针,未投的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想比较两个字符,看看哪一个是较长的词典和其排序的问题是我不知道如何比较单一字符我试图使用strcmp做像

I'm trying to compare two character and see which one is lexicographic longer and sorting by it problem is I'm not sure how to compare single character I tried doing it with strcmp like

struct example
{
 char code;
}
if (strcmp(i->code, j->code) < 0)
    return 1;

警告:传递âstrcmpâ的参数1时将整数指针,未作投

warning: passing argument 1 of âstrcmpâ makes pointer from integer without a cast

警告:传递âstrcmpâ的论点2时将整数指针,未作投

warning: passing argument 2 of âstrcmpâ makes pointer from integer without a cast

我知道STRCMP是字符串,我应该只是malloc和使焦炭code成一个字符串,而不是,或有另一种方式比较单一字符?

I know that strcmp is for strings, should I just malloc and make the char code into a string instead, or is there another way to compare single characters?

推荐答案

字符是一个整数类型。

您比较使用关系和平等运算符(字符对象&LT; = = ,等等)。

You compare char objects using the relational and equality operators (<, ==, etc.).

这篇关于从整数STRCMP指针,未投的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 23:19