C中的字符移位 [英] Char shifting in C
本文介绍了C中的字符移位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在库中找到可将字符前后移动的函数,例如我想要
:
I am trying to find the function in the library that shifts chars back and forward as I want for instance:
如果此函数消耗了'a '和一个要向前移动3的数字,它将被移动3次并且输出将为'd'。
if this function consumes 'a' and a number to shift forward 3 , it will be shifted 3 times and the output will be 'd'.
如果此函数使用了'5'和一个数字向前移动3,它将偏移3次,输出将为'8'。
if it this function consumes '5' and a number to shift forward 3 , it will be shifted 3 times and the output will be '8'.
我如何实现这一目标?
推荐答案
您无需调用函数即可执行此操作。只需将数字直接添加到字符中即可。
You don't need to call a function to do this. Just add the number to the character directly.
例如:
'a' + 3
计算为
'd'
这篇关于C中的字符移位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文