Hi I'v been working through another tut and have hit an issue, the program compiles fine but then crashes after printing "This is a test". I'm presuming it's an issue to do with pointer's but could be wrong. Also, I know this may sound odd, but my OS system is 64 bit and I was wondering if this could effect it?
Code:
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char str[] = "This is a test";
char *start, *end;
int len;
char t;
cout << "Original: " << str << endl;
len = strlen(str);
start = str;
end = &str[len-1];
while(start < end) {
t = *start;
*start = *end;
*end = t;
start++;
end++;
}
cout << "Reversed str: " << str << endl;
system("pause");
return 0;
}
Edit: Whoops sorry for wasting your time it should be end--. Although I am still interested to know if theirs any difference writing for 64 bit rather 32 bit.