Write code to reverse a C-Style String. (C-String means that “abcd” is represented as five characters, including the null character.)

Write code to reverse a C-Style String. (C-String means that “abcd” is represented as five characters, including the null character.)

SOLUTION This is a classic interview question. The only “gotcha” is to try to do it in place, and to be careful for the null character. 1 void reverse(char *str) { 2 char * end = str; 3 char tmp; 4 if (str) { 5 while (*end) { 6 ++end; 7 }...

Please like, share & comment!

0 0

Post Your Comment

8 + 10 =

Comments

Get In Touch