Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main(void) {
- char s1[20], s2[20];
- printf("1 番目の文字列(10 文字未満): ");
- scanf("%9s", s1);
- printf("2 番目の文字列(10 文字未満): ");
- scanf("%9s", s2);
- int cmp = strcmp(s1, s2);
- char *p1, *p2;
- if (cmp < 0) {
- p1 = s2;
- p2 = s1;
- } else {
- p1 = s1;
- p2 = s2;
- }
- strncat(p1, p2, 10);
- printf("大きい方の文字列に小さい方の文字列を連結すると、\n"
- "%s\n"
- "となります。\n",
- p1);
- printf("文字列全体の長さは %zd 文字です。", strlen(p1));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement