#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define NUM_LINES 4
int main ()
{
char arr[ NUM_LINES ][ 100 ];
int i, j, k; //for loop controls
int cnt = 0, start_pos = -1, end_pos = 0;
int len = 0;
char *replacement = "****";
strcpy( arr[ 0 ], "The test of\n" );
strcpy( arr[ 1 ], "There is a house in New Orleans city\n" );
strcpy( arr[ 2 ], "All good things must come to an end eventually.\n" );
strcpy( arr[ 3 ], "Formula1 is currently on tele so it is.\n" );
for( i = 0; i < NUM_LINES; i++ )
{
len = strlen( arr[ i ] );
for( j = 0; j < len; j++ )
{
if( start_pos == -1)
{
start_pos = j;
}
while( isalpha( arr[ i ][ j ] ) )
{
j++;
cnt++;
}
//just read a word
if( cnt == 4 )
{
strncpy( &arr[ i ][ j - 4 ], replacement, 4 );
}
cnt = 0;
start_pos = -1;
end_pos = 0;
}
printf( "%s", arr[ i ] );
}
return 0;
}