For example:input "I am a student." , output "student. am I". Be careful with the boundary.
#include<stdlib.h>
char input[13] = {'I',' ','a','m',' ','s','t','u','d','e','n','t','.'};
void reverseAll(char* input, int start, int end){
char temp;
while(start < end){
temp = input[start];
input[start] = input[end];
input[end] = temp;
start++;
end--;
}
}
void reverseWord(char* input, int len){
reverseAll(input, 0, len-1);
int i = 0, j = 0;
for(; i< len; i++){
if( input[i] == ' '){
reverseAll(input, j, i-1);
j = i + 1;
}
}
}
int main(){
reverseWord(input,13);
int i = 0;
for(; i < 13; i++){
printf("%c", input[i]);
}
getchar();
}