未分類

c言語で文字をつなげる方法

投稿日:

sprintf 関数を使って、result 変数に文字列 s1 と文字列 s2 を結合した文字列を出力することができる。

#include<stdio.h>
int main(void) {

char *s1 = "one";
char *s2 = "two";
char result[50];
sprintf(result, "%s%s",s1,s2);
printf("%s\n", result);

return 0;
}

結果

onetwo

-未分類

執筆者:


comment

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

関連記事

no image

tex で同値記号(⇔)を入力する方法

同値記号を入力するには、\Leftrightarrow を使う。 例 $b \leftrightarrow c$, $b \Leftrightarrow c$

no image

tex で行の色を1行ごとに交互につける

色を1行ごとに交互につけるには、\xcolor パッケージを使った上で、\rowcolors コマンドを使って色を指定する。 例 \usepackage[table]{xcolor} \begin{d …

no image

python で文字列の長さを表示する方法

len を使う。 例 length = len(‘文字列あいうえお’) print(str(length)) 結果 8

no image

tex でオーム記号を入力する方法

siunit のパッケージを使って、\si{\ohm} で入力する。 例 \usepackage{siunitx} \begin{document} \si{\ohm} \end{document} …

no image

tex でかけ算の記号 x (✕)を表示する

かけ算記号を表示するには、$\times$ を使う。 例 $2 \times 3$ 結果