Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to pass an array by reference in C++

void func (int arr[])
{
  for(int i=0;i<arr.size();i++)
    arr[i]=1;
}
int main()
{
	int arr[100];
  	func(arr);
}
Comment

how to pass arrays by reference c++

#include <iostream>
using namespace std;
void show( int *num) {
   cout<<*num;
}
int main() {
   int a[] = {3,2,1,6,7,4,5,0,10,8};
   for (int i=0; i<10; i++) {
      show (&a[i]);
   }
   return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ add input in 
Cpp :: move elements from vector to unordered_set 
Cpp :: variadic template in c++ 
Cpp :: how to make randomizer c++ 
Cpp :: C++ if...else...else if statement 
Cpp :: log base e synthax c++ 
Cpp :: array 2d to 1d 
Cpp :: what is throw in c++ 
Cpp :: initialize a vector with same values 
Cpp :: Accessing C++ Array Elements 
Cpp :: loops in c and c ++ 
Cpp :: or in c++ 
Cpp :: round c++ 
Cpp :: dangling pointer 
Cpp :: copy constructor for vector c++ 
Cpp :: create vectors of vectors c++ 
Cpp :: c++ last element of array 
Cpp :: use declaration to define a variable 
Cpp :: C++ Syntax for Passing Arrays as Function Parameters 
Cpp :: c++ map vector as keys 
Cpp :: c++ download 
Cpp :: how to get characters through their ascii value in c++ 
Cpp :: c++ file handiling 
Cpp :: *= c++ 
Cpp :: nmake.exe is not found in the windows 
Cpp :: texorpdfstring math in title latex 
Cpp :: move semantics in c++ 
Cpp :: I/O Redirection in C++ 
Cpp :: c++ program to convert celsius to fahrenheit 
Cpp :: && in cpp 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =