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

void InsertDots(char * inputString, int * inputK)
{
    char * outputString = malloc(255 * sizeof(char));
    char * dotString = "...";
    
    strncpy(outputString,inputString,*inputK);
    strcat(outputString, dotString);
    
    
    printf("%s \n", outputString);
}

void CheckLength(char * inputString, int * inputK)
{
    long stringLength = strlen(inputString);
    
    if(stringLength > *inputK)
    {
        InsertDots(inputString, inputK);
    }
    else
    {
        printf("%s \n", inputString);
    }
}

void ReadInputS(char * inputString)
{
    //printf("Enter your string: \n");
    scanf("%s", inputString);
}

void ReadInputK(int * inputK)
{
    //printf("Enter value of K: \n");
    scanf("%d", inputK);
    
    while (*inputK > 100)
    {
        printf("Wrong input, value needs to be less 100 \n");
        ReadInputK(inputK);
        if(*inputK <= 100)
        {
          break;
        }
    }
}

int main(int argc, const char * argv[])
{

    int *inputK = malloc(255 * sizeof(int));
    char *inputString = malloc(255 * sizeof(char));
    
    
    ReadInputK(inputK);
    ReadInputS(inputString);
    CheckLength(inputString, inputK);
    
    return 0;
}
