Well, guys, my internet went out last night, so I worked on this. I went my trusty new book (the one in my avatar), and it told me what Salem stated. I guess it wasn't that hard after all. Also, I think it didn't appear to be changing it because the 'newArray really contained the same elements as the original, and assigning the original to newArray did no good. I fixed that problem too. Now everything works:
Code:
#include <iostream>
#include <cstring>
using namespace std;
void stringReverser(char* array, int len);
int main()
{
char array[50];
cout<<"Please enter a string to have it reversed: ";
cin.get(array,49);
int length = strlen(array);
stringReverser(array,length);
cout<<"Your string reversed is: "<<array<<endl;
system("PAUSE");
return 0;
}
void stringReverser(char* array, int len)
{
char newArray[50];
int i = 0;
for(;array[i];i++)
{
newArray[i] = array[i];
}
int j = len-1;
for(int i = 0;i<len;i++,j--)
{
newArray[i]=array[j];
}
for(int i = 0;i<len;i++)
{
array[i]=newArray[i];
}
}