Donc, ci-dessous j'ai un code en C++ qui est censé inverser les arguments dans un vecteur, mais pas la séquence. J'ai énuméré mes problèmes comme sidenotes dans le code ci-dessous. La fonction inverse est censé inverser chaque argument, et la fonction principale produit juste les mots inversés dans la même ordre Par exemple, le programme (« un deux trois quatre ») = Ruof eerth owt enoLe programme ne compilera pas
#include <iostream>
#include <string>
using namespace std;
int invert(string normal)
{
string inverted;
for (int num=normal.size()-1; num>=0; num--)
{
inverted.append(normal[num]); //I don't know how to get each character
//I need another command for append
}
return **inverted**; <----
}
int main(int argc, char* argv[])
{
string text;
for (int a=1; a<argc; a++)
{
text.append(invert(argv[a])); //Can't run the invert function
text.append(" ");
}
cout << text << endl;
return 0;
}