Well, I've recently picked up a book that hasn't been touched in half a year, and started learning C++ again. As a sort of "refresher", I did some work on pointers, as they are some of the hardest things someone new will come to face.
Completed a project which reverses strings, but I'm looking for new ideas.
here is the code:
Completed a project which reverses strings, but I'm looking for new ideas.
here is the code:
Code:
#include <iostream>
#include <cstring>
using namespace std;
void reverseString(char* str);
int main(int argc, char** argv) {
char str[] = "This is a test";
reverseString(str);
cout<<str<<'\n';
system("pause");
return 0;
}
void reverseString(char* str) {
char *start = str, *end=&str[strlen(str)-1], t;
while(start<end) {
t = *start;
*start = *end;
*end = t;
start++;
end--;
}
}

