write a program to input your choice and following r for reverse word and s for special word
Answers
Answered by
0
Answer:
#include <stdio.h>
void reverse(char* begin, char* end)
{
char temp;
while (begin < end) {
temp = *begin;
*begin++ = *end;
*end-- = temp;
}
}
void reverseWords(char* s)
{
char* word_begin = s;
while (*temp)
{
temp++;
if (*temp == '\0') {
reverse(word_begin, temp - 1);
}
else if (*temp == ' ') {
reverse(word_begin, temp - 1);
word_begin = temp + 1;
}
}
reverse(s, temp - 1);
}
int main()
{
char s[] = "i like this program very much";
char* temp = s;
reverseWords(s);
printf("%s", s);
return 0;
}
Similar questions