I'm new to this website and I am pretty excited to be a part of this community now.
I am taking my second course in c++ right now and I have this problem where i need to find a way to ask the user to input a number and that number will be set as the size of the array. I know i'm suppose to implement pointers in some way but i'm having trouble with it. Any tips?
void GetInfo(const int* numStudents)
const int *numStudents;
cout <<"enter amount of students:" << endl;
cin >> y;
numStudents = &y;
//numStudents = school;
Line 4: numStudents has already been declared as an argument.
Line 9: Are you trying to declare any array? You need a type and a name. You have only one of the two (not sure which). Also, you can't declare any array with a variable.
PLEASE USE CODE TAGS (the <> formatting button). Code tags make it easier to help you.
"I have this problem where i need to find a way to ask the user to input a number and that number will be set as the size of the array."
This is not possible. An array's length must be constant and known during a declaration context. Some compilers, such as GCC, support non-constant array lengths as an extension, however. To create an array during run-time, you will need to reserve memory from the heap. Here's an example:
1 2 3 4 5 6 7 8 9 10 11 12 13
int main( )
std::cin >> Value_; // Get the length of the array.
if(Value_ > 0)
Memory_ = newint[Value_];
// We're done with the memory.
delete  Memory_;