편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2021.05.31

    strcat 儆


    strcat함수를 구현하여 실행시키는데 자꾸 끝에 가 붙네요. 어디가 틀린 걸까요? 아 그리고 배열에 scanf_s 쓰면 안되던데 왜 그런 걸까요?

    #define _CRT_SECURE_NO_WARNINGS
    #include <stdio.h>
    int strlen(char* a)
    {
        int i=0;
        while (a[i] != '\0')
            i++;
        return i;
    }
    void strcat(char* b, char* c)
    {
        int n = strlen(b), i;
        for (i = n; i < n + strlen(c); i++)
            b[i] = c[i - n];
    }
    
    int main(void)
    {
        char s[50], e[50];
        scanf("%s", s);
        scanf("%s", e);
        printf("%d\n", strlen(s));
        printf("%d\n", strlen(e));
        strcat(s, e);
        printf("%s\n", s);
        return 0;
    }
    
  • 프로필 알 수 없는 사용자님의 편집
    날짜2021.05.30

    strcat 儆


    strcat함수를 구현하여 실행시키는데 자꾸 끝에 儆가 붙네요. 어디가 틀린 걸까요? 아 그리고 배열에 scanf_s 쓰면 안되던데 왜 그런 걸까요?

    define _CRT_SECURE_NO_WARNINGS

    include

    int strlen(char* a) { int i=0; while (a[i] != '\0') i++; return i; } void strcat(char* b, char* c) { int n = strlen(b), i; for (i = n; i < n + strlen(c); i++) b[i] = c[i - n]; }

    int main(void) { char s[50], e[50]; scanf("%s", s); scanf("%s", e); printf("%d\n", strlen(s)); printf("%d\n", strlen(e)); strcat(s, e); printf("%s\n", s); return 0; }