method 1: char buf[4]; buf[0] = a_buf[30]; buf[1] = a_buf[31]; buf[2] = a_buf[32]; buf[3] = '\0'; method 2: char *cp = &(a_buf[30]); use memcpy copy 3 byte form cp to buf then set buf[3] = '\0'