implement task4_6

implement task4_6
Minor update for task4_5: replace shared_ptr with shared_array for char[]
fix compiler warnings