[ create a new paste ] login | about

Link: http://codepad.org/VNdg2sn4    [ raw code | output | fork ]

C, pasted on Oct 30:
#include <stdio.h>

int main(){
    size_t i, j, bgn, end;
    const char text[] = "This is  sample text  for  find   max  length";
    for( i = j = bgn = end = 0; text[i]; i++ )
    {
        if
        ( 
            text[i] == ' ' || text[i] == '\t' || text[i] == '\n' || text[i] == '\r'   /*isspace*/
            ||
            text[i] == '.' || text[i] == ','  || text[i] == '?'  || text[i] == '!'    /*ispunkt*/
        )
        {
            //зустріли деліметр
            if( i - j > end - bgn )
            {
                bgn = j;
                end = i;
            }
            j = i + 1;
        }
    }
    printf("maxword : \n");
    for( i = bgn; i <= end; i++ )
        printf("%c", text[i]);
    return 0;
}


Output:
1
2
maxword : 
sample 


Create a new paste based on this one


Comments: