how to perform reversing a sentence Word by Word in C?

后端 未结 12 1346
伪装坚强ぢ
伪装坚强ぢ 2021-01-25 04:49
#include 

int main(void)
{
  int i,j;
  int wordstart = -1;
  int wordend = -1;
  char words[]= \"this is a test\";
  char temp;

  // Reverse each word
         


        
12条回答
  •  隐瞒了意图╮
    2021-01-25 05:11

    You can create a double linked list as a base data structure. Then, iterate through the words and insert them in the list as you find them.

    When you reach the end of the sentence, simply traverse the list backwards and print the words as you go through them

提交回复
热议问题