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
雑記
投稿日:
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
執筆者:seyanen
関連記事
c言語では、sprintf 関数を使って文字列を合成(連結)することができる。いっぽう、c++ では、文字列を string で表して「+」演算子で文字列を合成することができる。 例 #include …
python3 で辞書(dict) の for ループでキーと値を取得する
キーと値を取得するには次のようにする。キーは dict のループ、値は dict の values() のループで取得できる。 例 mydictionary = {‘color’: ‘白’, ‘ani …
physics パッケージを使って、\divisionsymbol で割り算記号が入力できる。 例 \usepackage{physics} \begin{document} $2 \division …
量子科学では、「プランク定数」を h で表すが、h を 2π で割った量を エイチバーで表すことがある。 tex での書き方 $\hbar$ 結果 リベンジH 4【電子書籍】[ 仙道ますみ ]価格:6 …
2023/01/18
matplotlib のグラフ作成と gnuplot との対応 比較
2022/10/14
pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。