S
sherifffruitfly
Hi all,
I just wrote this up real quick, and it seems to work with a bunch of
input strings (with and without spaces) except for the one in the code
below:
string input = "this is a string";
int length = input.Length-1;
char [] reverseMe = input.ToCharArray();
char temp;
for (int i = 0; i<length / 2; i++)
{
temp = reverseMe;
reverseMe = reverseMe[length - i];
reverseMe[length - i] = temp;
}
string done = new string(reverseMe);
MessageBox.Show(done);
Expected output: gnirts a si siht
Actual output: gnirts asi siht
What's with the missing space between the "is" and the "a"?
thanks in advance,
cdj
I just wrote this up real quick, and it seems to work with a bunch of
input strings (with and without spaces) except for the one in the code
below:
string input = "this is a string";
int length = input.Length-1;
char [] reverseMe = input.ToCharArray();
char temp;
for (int i = 0; i<length / 2; i++)
{
temp = reverseMe;
reverseMe = reverseMe[length - i];
reverseMe[length - i] = temp;
}
string done = new string(reverseMe);
MessageBox.Show(done);
Expected output: gnirts a si siht
Actual output: gnirts asi siht
What's with the missing space between the "is" and the "a"?
thanks in advance,
cdj