c++ function return array
C++
#include <iostream>
#include <ctime>
using namespace std;
// function to generate and retrun random numbers.
int * getRandom( ) {
static int r[10];
// set the seed
srand( (unsigned)time( NULL ) );
for (int i = 0; i < 10; ++i) {
r[i] = rand();
cout << r[i] << endl;
}
return r;
}
// main function to call above defined function.
int main () {
// a pointer to an int.
int *p;
p = getRandom();
for ( int i = 0; i < 10; i++ ) {
cout << "*(p + " << i << ") : ";
cout << *(p + i) << endl;
}
return 0;
}
Also in C++:
- Title
- stringstream in c++
- Category
- C++
- Title
- sfml basic program
- Category
- C++
- Title
- c++ passing two dimensional array to function
- Category
- C++
- Title
- C++ int to char*
- Category
- C++
- Title
- preorder traversal c++
- Category
- C++
- Title
- std::iomanip c++
- Category
- C++
- Title
- max in c++
- Category
- C++
- Title
- split string at index c++
- Category
- C++
- Title
- getline in c++
- Category
- C++
- Title
- c++ create object
- Category
- C++
- Title
- for c++
- Category
- C++
- Title
- insert at position in vector c++
- Category
- C++
- Title
- convert stirng to int c++
- Category
- C++
- Title
- translate
- Category
- C++
- Title
- how to output text in c++
- Category
- C++
- Title
- c++ try
- Category
- C++
- Title
- what is meaning of 64 bit integer in c++
- Category
- C++
- Title
- how to declare a function in c++
- Category
- C++
- Title
- how to have a queue as a parameter in c++
- Category
- C++
- Title
- c++ char if
- Category
- C++
- Title
- create a dictionary cpp
- Category
- C++
- Title
- console colors in C++
- Category
- C++
- Title
- hobo 8
- Category
- C++
- Title
- c++ read matttrix from text file
- Category
- C++
- Title
- map.erase in c++
- Category
- C++
- Title
- cloud hosting
- Category
- C++
- Title
- C++ remove element from set
- Category
- C++
- Title
- c++ function return array
- Category
- C++
- Title
- residuo en lenguaje c
- Category
- C++
- Title
- *min_element in c++
- Category
- C++
- Title
- singleton c++
- Category
- C++
- Title
- rand c++
- Category
- C++
- Title
- unordered_set in c++ and ordered set diff
- Category
- C++
- Title
- c++ class constructor
- Category
- C++
- Title
- iterate 2d array c++
- Category
- C++
- Title
- opperanf >> c++
- Category
- C++
- Title
- runtime array size c++
- Category
- C++
- Title
- quick sort predefined function in c++
- Category
- C++
- Title
- programa para saber si un numero es primo
- Category
- C++
- Title
- length of string c++
- Category
- C++
- Title
- pass by reference c++
- Category
- C++
- Title
- converting char to int in c++
- Category
- C++
- Title
- mark occurances of elements in array cpp
- Category
- C++
- Title
- find in string c++
- Category
- C++
- Title
- appending a double to a string c++
- Category
- C++
- Title
- floor() in c++
- Category
- C++
- Title
- c++ cout int
- Category
- C++
- Title
- c++ vector iterator
- Category
- C++
- Title
- % operator in c++
- Category
- C++
- Title
- how to get a letter from the user c++ string
- Category
- C++
- Title
- length of array in cpp
- Category
- C++
- Title
- C++ w3schools
- Category
- C++
- Title
- initialize 3d vector c++
- Category
- C++
- Title
- c++ push multiple elements to vector
- Category
- C++
- Title
- c++ dereference a pointer
- Category
- C++
- Title
- how to sort in descending order c++
- Category
- C++
- Title
- pointers in cpp
- Category
- C++
- Title
- c++ crash windows
- Category
- C++
- Title
- decimal to hex cpp
- Category
- C++
- Title
- c++ pi
- Category
- C++
- Title
- binary serach in c++
- Category
- C++
- Title
- how to initialize a vector in c++
- Category
- C++
- Title
- error: redefinition of ‘class Customer’
- Category
- C++
- Title
- repeating character in c++
- Category
- C++
- Title
- how to find absolute value in c++
- Category
- C++
- Title
- c++ map find
- Category
- C++
- Title
- what is atoi in strinf
- Category
- C++
- Title
- c++ switch case statement
- Category
- C++
- Title
- preorder traversal
- Category
- C++
- Title
- bellman ford algorithm cp algorithm
- Category
- C++
- Title
- factorial in c++
- Category
- C++
- Title
- length of 2d array c++
- Category
- C++
- Title
- how to convert n space separated integers in c++
- Category
- C++
- Title
- c++ reading string
- Category
- C++
- Title
- swapo algorit
- Category
- C++
- Title
- __builtin_ctz
- Category
- C++
- Title
- append string to another string c++
- Category
- C++
- Title
- including cpp header file in c++
- Category
- C++
- Title
- c++ vector
- Category
- C++
- Title
- Find the duplicate in an array of N integers.
- Category
- C++
- Title
- c++ map insert
- Category
- C++
- Title
- UPARAM(ref)
- Category
- C++
- Title
- c++ set console title
- Category
- C++
- Title
- file objects in c++
- Category
- C++
- Title
- private and public in namespace cpp
- Category
- C++
- Title
- root to leaf path print
- Category
- C++
- Title
- runtime error in c++
- Category
- C++
- Title
- lower bound c++ for array in decreasing order
- Category
- C++
- Title
- c++ program how to let the user choose different game modes
- Category
- C++
- Title
- variabili in c++
- Category
- C++
- Title
- vector stl c++
- Category
- C++
- Title
- how to run a c++ program in the background
- Category
- C++
- Title
- c++ ambigous error
- Category
- C++
- Title
- intersection between vector c++
- Category
- C++
- Title
- int max in c++
- Category
- C++
- Title
- nginx linux
- Category
- C++
- Title
- sum of two numbers c++
- Category
- C++
- Title
- double to string c++
- Category
- C++
- Title
- c++ rainbow text
- Category
- C++
- Title
- linkedlist implementation in c++
- Category
- C++