文字列にコンテンツを書き込み、同時に別の文字列をそこに入れることは可能ですか?
char str[50], *test;
scanf("%s", str);
test = "123 %s 123", str;
printf("%s\n", test);
scanf「abc」に書き込むことを検討してください
出力する方法は次のとおりです。
- 123 abc 123
文字列にコンテンツを書き込み、同時に別の文字列をそこに入れることは可能ですか?
char str[50], *test;
scanf("%s", str);
test = "123 %s 123", str;
printf("%s\n", test);
scanf「abc」に書き込むことを検討してください
出力する方法は次のとおりです。
snprintf()
のようprintf
な書式設定を行い、結果を文字配列に入れるために使用できます。
char str[50], test[128];
scanf("%s", str);
snprintf(test, sizeof(test), "123 %s 123", str);
printf("%s\n", test);