Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ array pointer

void func( int* pointer){
  int i = 0 ;
  std::cout << *(pointer+i) ; // list[i]
};

int list[]={1,2,3,9};
int* pointer = list ;
func(pointer);
Comment

pointers and arrays in c++

#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;
    }

}
Comment

C++ Pointers and Arrays

int *ptr;
int arr[5];

// store the address of the first
// element of arr in ptr
ptr = arr;
Comment

arrays and pointers

#include<stdio.h>

int main()
{
    int arr[5] = {10, 20, 30, 40, 50}, i;

    for(i = 0; i < 5; i++)
        printf("value stored in arr[%d] = %d
",i,*(arr+i));

    return 0;
}
Comment

arrays and pointers

#include<stdio.h>

int main()
{
    int arr[5] = {10, 20, 30, 40, 50}, i;

    for(i = 0; i < 5; i++)
        printf("Address of arr[%d] = %p
",i,arr+i);

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: find factorial in c++ using class 
Cpp :: custom slider cpt wordpress theme 
Cpp :: the difference between i++ and ++i 
Cpp :: how to insert in a queue c++ 
Cpp :: remove linked list elements leetcode 
Cpp :: C++ Taking Multiple Inputs 
Cpp :: valid parentheses in c++ 
Cpp :: public method 
Cpp :: assign value to a pointer 
Cpp :: << in C++ 
Cpp :: c++ get index of map element 
Cpp :: replace a char in string c++ at a specific index 
Cpp :: linkedlist in c++ 
Cpp :: how togreper 
Cpp :: cpp algorithm iota 
Cpp :: enter items in array until enter is pressed c++ 
Cpp :: wgat is duble in c++ 
Cpp :: i++ i-- 
Cpp :: no of balanced substrings 
Cpp :: c++ write number to registry 
Cpp :: the number of ones int bitset 
Cpp :: C++ using a member function of a class to pass parameters to a thread 
Cpp :: c ++ Prefix Sum of Matrix (Or 2D Array) 
Cpp :: C++ Multilevel Inheritance 
Cpp :: ue4 c++ enum variable declaration 
Cpp :: bnchch 
Cpp :: assegnare valori in c++ 
Cpp :: sort using comparator anonymous function c++ 
Cpp :: how to find the sum of elements in a stack in cpp 
Cpp :: C++ Rectangular Form 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =