我怎样才能重写这个程序,让它以相反的顺序打印文本的值

How can i rewrite this program so that it will print the value of text in reverse order

#include<iostream.h>
#include<conio.h>
#include<string.h>

char text[]="A nut for a jar of tuna";
int txtposition,txtlength;

void main()
{
    clrscr();
    txtlength=Strlen(text);

    for(txtposition=0; txtposition<=txtlength;txtposition++)
     { 
         cout<<text[txtposition]; 
     }
getch();
}

如何重写这个程序,使其以相反的顺序打印文本的值?

#include<iostream.h>
#include<conio.h>
#include<string.h>

char text[]="A nut for a jar of tuna";
int txtposition,txtlength;

void main()
{
    clrscr();
    txtlength=Strlen(text);

    for(txtposition= txtlength-1 ; txtposition>=0;txtposition--)
     { 
         cout<<text[txtposition]; 
     }
    getch();
}

您可以使用@Prashant 建议的答案,也可以创建另一个 char reversetext[] 来保存反向文本。这样您就可以根据需要使用它了。

此外,如果您尝试反转每个单词,则需要不同的更长算法。如果您正在寻找那个,请告诉我。