#include <stdio.h>
#include <stdlib.h>

#define BUFF_SZ 256

void put_stringn(const char s[], int n) {
    if (n < 0) return;

    int idx = 0;

    for (int i = 0; i < n; i++) {
        idx = 0;
        while (s[idx] != '\0' && idx < BUFF_SZ) {
            if (s[idx] == '\n') {
                idx++;
                continue;
            }
            putchar(s[idx]);
            idx++;
        }
    }

    putchar('\0');
}

int main(void) {
    char *buff = (char*)calloc(sizeof(char), BUFF_SZ);
    int n = 0;

    printf("Input String: ");
    fgets(buff, BUFF_SZ, stdin);

    printf("Input Repeat Num: ");
    scanf("%d", &n);

    put_stringn(buff, n);
    putchar('\n');

    free(buff);

    return 0;
}
