void func( int* pointer){
int i = 0 ;
std::cout << *(pointer+i) ; // list[i]
};
int list[]={1,2,3,9};
int* pointer = list ;
func(pointer);
#include <iostream>
using namespace std;
int main()
{
int x[3] = { 5,9,20 };
int* p = x;
cout << p << endl; //prints the address of x[0]
cout << *p << endl; //prints the value of x[0] (5)
//printing the array
for (int i = 0; i < 3; i++){
cout << p[i] << endl;
//or
cout << *(p + i) << endl;
}
}
int *ptr;
int arr[5];
// store the address of the first
// element of arr in ptr
ptr = arr;
Code Example |
---|
Cpp :: how to access a vector member by its index |
Cpp :: c++ string_t to string |
Cpp :: max pooling in c++ |
Cpp :: constrain function in arduino |
Cpp :: cpp oop |
Cpp :: program to swap max and min in matrix |
Cpp :: min heap stl |
Cpp :: full implementation of binary search tree in C++ |
Cpp :: char array declaration c++ |
Cpp :: accumulate in cpp |
Cpp :: potato |
Cpp :: c++ add input in |
Cpp :: lists occurrences of characters in the string c++ |
Cpp :: c++ split string |
Cpp :: assign one vector to another c++ |
Cpp :: async multi thread |
Cpp :: c++ write string |
Cpp :: round c++ |
Cpp :: for_each c++ |
Cpp :: valid parentheses in c++ |
Cpp :: dynamic memory in c++ |
Cpp :: c++ structs |
Cpp :: c++ stl |
Cpp :: cuda shared array |
Cpp :: recherche recursive le max dans une liste |
Cpp :: faster solutions |
Cpp :: time_t c++ stack overflow |
Cpp :: nmake.exe is not found in the windows |
Cpp :: c++ restrict template types |
Cpp :: c++ if |