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
関連記事
文字色を RGB で指定する。例では、\definecolor で、「samplecolor」という色を定義して使っている。 例 \usepackage{xcolor}\begin{document} …
2023/01/18
matplotlib のグラフ作成と gnuplot との対応 比較
2022/10/14
pythonで配列(リスト)の、ある要素がわかっているときにその次の要素を取得する方法。