I am trying to reverse the characters for each command line argument.
This is the only code inside my main method:
for(int z = 1; z < argc; z++) //Loop through every argument
{
string arg = argv[z]; //Grab the argument
string rebuildString; //Create a string to build the result
for(int i = arg.size()-1; i >= 0; i--) //Loop through characters backwards
{
char c = arg[i];
rebuildString += c;
}
char *rebuildChars; //So since argv is an array of pointers, I create a pointer here.
*rebuildChars = rebuildString.c_str(); //Assign the value of the pointer
argv[z] = rebuildChars; //Assign the current argument to the new value.
}
for(int x = 1; x < argc; x++)
{
cout << argv[x];
}
Something is going wrong with my pointers and I am getting some incompatible type errors. Can anyone point out what's going wrong?