如何比较 ASCII 值
我想将字母的 ASCII 值存储到变量中,我该怎么做?
例如:
r ASCII variable = 82
main()
{
character = "character read from a file";
variable= "r ascii"; //(in this case 82), the problem is that the letter is always variable.;
printf( "the value of %c is %d, character, variable)
}
我该怎么做?
另请注意,如何逐个字符读取 .txt
文件?所以它可以保存在字符变量上。
I want to store the ASCII value of a letter into a variable, how can I do this?
for example :
r ASCII variable = 82
main()
{
character = "character read from a file";
variable= "r ascii"; //(in this case 82), the problem is that the letter is always variable.;
printf( "the value of %c is %d, character, variable)
}
How can I do this?
Also on an extra note, how could I read a .txt
file character by character? so It could be saved on the character variable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需执行以下操作:
在 C 中,
char
变量由其 ASCII 整数值表示,因此,如果您有以下内容:相同:
与以下内容 甚至可以混合它们:
Just do:
In C,
char
variables are represented by their ASCII integer value, so, if you have this:Is the same as:
You can even mix them:
如果您只想将
ascii
值保存到整数变量中,只需使用它
If you just want to save the
ascii
value onto an integer variablejust use this