Hello I am new in the forum and newbie in C++. Fist of all I whould like to thank Juan Soulie for the very helpful tutorial. Now my question, I want to have in a program an array and a function. The function have to take some values from tha array so tha array must be global variable and it's declaration will be out of the main function. And here is the problem, I don't know from the begining the size of the array. The size will be found in execution from a file which will be read in the main function.
Your help is wellcome, thank you.
#include <iostream>
usingnamespace std;
int *a;//a pointer to the array
void function(){
a[0]++;//do something with the array
}
int main(){
int len;
len=5;
a=newint[len];//create the array
a[0]=5;
cout<<a[0]<<endl;
function();
cout<<a[0]<<endl;
int i;cin>>i;
return 0;
}