94 answers Pizza toppings Playstation 94 Poker 94 Reptiles 94 Rodents 94 Skiing 94
Interview Question reverse | Silverlight tips
Friday , 31 July 2015
Home » Tag Archives: Interview Question reverse

Tag Archives: Interview Question reverse

How to reverse a C-Style String Interview Question

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


This is a classic interview question   The only “gotcha” is to try to do it in place, and to be care-ful for the null character

void reverse(char *str) {
   char * end = str;
   char tmp;
   if (str) {
     while (*end) {
     while (str < end) {
        tmp = *str;
        *str++ = *end;
        *end-- = tmp;