cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Declare pointer to array
Declare pointer to array
Jul 5, 2015 at 8:55am UTC
MM7
(2)
I have a function that writes the bytes of a file to ram.
To get a value from a specific ram adress I do
int
*pointerToSmth = (
int
*) (someAdress);
But how do I declare a pointer to an array?
Jul 5, 2015 at 9:01am UTC
Peter87
(11234)
Note that you can use array syntax on pointers too. If the pointer points to the first element in the array you can use the subscript operator to read and assign values from the array the same way you do with a normal array type.
1
2
3
int
*arr = .... arr[0] = 4; cout << arr[1];
Last edited on
Jul 5, 2015 at 9:03am UTC
Jul 5, 2015 at 9:06am UTC
MM7
(2)
Thank you. That was exacly that I was searching for.
Topic archived. No new replies allowed.