Hello, I have read various pointer tutorials but I still don't understand the concept of using them.
I am using Dev-C++ as my compiler.
If it would be possible could someone point my into the right direction by providing an example of how a pointer is used correctly.
I collected this code from a website using pointers.
This outputs 6.Code:#include <iostream>
using namespace std;
int main()
{
int myval = 7;
int* p_myval = &myval;
*p_myval = 6;
cout << myval;
cin.get();
}
Why cannot I just do this?
This also outputs 6.Code:#include <iostream>
using namespace std;
int main()
{
int myval = 7;
myval = 6;
cout << myval;
cin.get();
}
So I cannot understand the use of pointers, if someone can briefly explain this that would be awesome.
