[ C ] Sample Code - 문자열 자르기 샘플코드

 

#include <stdio.h>
#include <string.h>

int main() {
    char input[] = "Hello, World!";
    char output[5];
    int start = 2;
    int length = 4;

    strncpy(output, input + start, length);
    output[length] = '\0';

    printf("%s\n", output);

    return 0;
}