Hi there,
I am starting out with the C++ (like everyone else) and I am experimenting trying to become a little more familiar with it.
Right now I am playing with pointers. From what I understand, a pointer can be used to refer to a variable in memory by either the data or memory location.
What I am trying to do is assign a pointer to a string and read the information back through the pointer. Is this even possible?
Here is my code..... Any input would be greatly appreciated
Code:#include <iostream> using namespace std; char MyString[15]; int Some_Function(); char *pointer; int main(int argc, char *argv[]) { Some_Function(); cout << endl; system("PAUSE"); return 0; } int Some_Function() { pointer = &MyString[15]; char MyString[15] = "This is a test"; cout << "Original string: " << MyString << endl; cout << "String from pointer: " << *pointer; return 0; }