C ++ Value Return产生true / false的函数 [英] C++ Value Return Function that produces a true/false

查看:77
本文介绍了C ++ Value Return产生true / false的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的第一个学期C ++结束时,我不知道该怎么做才能使这个程序符合要求的规范。赋值如下:


编写一个名为ignoreCaseCompare()的函数,它有两个字符(char)参数。如果收到的两个字符代表相同的字母,则该函数应返回true,即使案例不一致。否则,该函数应返回false。然后,编写一个使用ignoreCaseCompare()的简单main()函数。


附加说明:


这是函数标题:

bool ignoreCaseCompare(char c1,char c2)


{


//编写代码来比较c1与c2并返回true / false


}



这就是我所拥有的:

I am at the end of my first semester of C++, and I''m not sure what I should do to make this program meet the requested specifications. The assignment is as follows:

Write a function called ignoreCaseCompare() that has two character (char) parameters. The function should return true if the two characters received represent the same letter, even if the case does not agree. Otherwise, the function should return false. Then, write a simple main() function that uses your ignoreCaseCompare().

Additional instructions:

Here is the function heading:
bool ignoreCaseCompare(char c1, char c2)

{

//Write the code to compare c1 with c2 and return true/false

}


Here is what I have:

展开 | 选择 | Wrap | 行号

推荐答案

在ignoreCaseCompare中移动toupper
move toupper inside ignoreCaseCompare


你的主要函数不调用ignoreCaseCompare()。
Your main function doesn''t call ignoreCaseCompare().


你想对原始字符调用ignoreCaseCompare(),而不是toupper等价物。将toupper和比较部分移动到函数本身。
You want to call ignoreCaseCompare() on the original characters, not the toupper equivalents. Move the toupper and the comparison parts into the function itself.


这篇关于C ++ Value Return产生true / false的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆