未分類

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

python3 で、文字列を一文字ずつのリストに変換する方法

string を list() で変換すれば良い。 例 str1 = ‘Good morning.’ list1 = list(str1) print(list1) 結果 [‘G’, ‘o’, ‘o’ …

no image

tex で「デルタ」δ・Δ を入力する方法

小文字のデルタ:δ大文字のデルタ:Δ 例 $\delta, \Delta$ 結果

no image

tex で三角形の相似記号を入力する

\sim を使う。 例 $\triangle{ABC} \sim \triangle{DEF}$ 結果

no image

matplotlib で x, y軸・タイトルのフォントサイズを調整する

ラベルの fontsize で指定する。 例 import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 2, 100) …

no image

tex で数式モード内に普通の文字列を入力する方法

\textrm を使う。 例 $$y = f (x) \hspace{1cm} \textrm{This is a function.}$$ 結果