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

int main()
{
    char text[256],*p,*v,cuv[30];
    int max;
    printf("Introduceti textul : ");
    gets(text);
    printf("Introduceti lungimea maxima : ");
    scanf("%d",&max);
    v=&text;
    while(strpbrk(v," ")!=NULL){
        p=strpbrk(v," ");
        if(p-v<=max){
            strncpy(cuv,v,p-v); cuv[p-v]=0;
            printf("%s\n",cuv);
        }
    //printf("\n%s\n",v);
    v=p+1;
    }
    if(strlen(v)<=max)printf("%s",v);
    return 0;
}
