Added a swap function which swaps char values, eliminates the need for a temp char array

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>