I was asked this question in an interview
I was supposed to reverse the array of character in its own place not to reverse the whole array of character.
if
char *ch="krishna is the best";
then I was supposed to reverse in such a way that the output should be like
anhsirk si eht tseb
I could not write the code in Interview .Can anyone suggest me how to write to do this.?
Can it be done with the help of pointers ?
if the interviewer had not told me to reverse it to its own place then would if be easy to deal with using another array of character of array,which would have the new character string after reversing it?
No can do, this is a pointer to a read-only string literal. Let us imagine that your interviewer knew C and wrote this instead:
Then you could do something like this: