未分類

C言語で文字をアルファベット順にずらす

投稿日:2020年11月11日 更新日:

C言語で文字をずらすには、char 型の変数に1を加えればよい。

#include <stdio.h>
int main(void)
{
char c;
c = 'a';
c++;
printf("c is %c\n",c);
return 0;
}

結果

c is b

‘a’ という文字(char)を1つずらして、b に変更する。


-未分類

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

関連記事

no image

python3 で、ファイルの文字列の1行目を出力する

ファイルを読み込んで、1行目だけをコンソールに出力するには readlines() を使う。 例 f = open(“data.txt”) lines = f.readlines() print(li …

no image

tex の積分範囲の分数サイズを変更する方法

定積分の分数の大きさを調整するには、\mbox のサイズ指定を \small や \normalsize や \large 等に設定すると良い。 例 $\displaystyle \int _0 ^{ …

no image

tex で脚注を表示する方法

\footnote を使う。 例 \footnote{this is a footnote.} 結果

no image

tex で方程式を文書の中央揃えにする(eqnarray→ align)

amsmath パッケージを使ったうえで、align を使う。次の例では eqnarray の代わりに、align を使っている。 例 \usepackage {amsmath}  \begin{do …

no image

C言語でchar文字列の長さを取得する (strlen)

strlen 関数を使って取得すればよい。sizeof という関数もあるが、strlen と振る舞いが異なるので注意。 例 #include<stdio.h> #include<strin …