Answer the question
In order to leave comments, you need to log in
Why can't I pass a pointer to a function?
#include<iostream>
#include<time.h>
using namespace std;
void Function1(int* ptr, int& size);
void main() {
setlocale(LC_ALL, "Rus");
int* ptr = nullptr;
int size = 10;
Function1(ptr, size);
cout << endl;
}
void Function1(int* ptr, int& size) {
for (int i = 0; i < size; ++i) {
ptr[i] = rand() % (20 - 0 + 1) - 0;
cout << ptr[i] << ' ';
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question