I don't understand why this program will not compile. I know the program is kind of long but I would really appreciate any help. I am not very advanced in C++ so I figured some of you guys would be able to pick out the problem. Thanks!
#include<iostream>
//#include<cstdef>
#include<iomanip>
#include<fstream>
#include"squirrels.h"
#include"tree.h"
#include"nuts.h"
#include"hoard.h"
usingnamespace std;
int main()
{
int numSq[];
int numTree[];
int skipFactor;
Tree nuts;
Squirrel squirrel;
cout<<"Please enter the number of squirrels: "<<endl;
cin>>numSq;
for(int i=0;i<=numSq;++i){
numSq[i];
}
cout<<"Please enter the number of trees: "<<endl;
cin>>numTree;
for(int i=0;i<=numTree;++i){
numTree[i];
}
cout<<"Please enter the skip factor of squirrel: "<<i<<endl;
cin>>skipFactor;
set_skip_factor(skipfactor);
int count=0;
while(nuts.nuts_left!=0){
++count;
cout<<"Round: "<<count<<endl;
for(int i=0;i<=numTree;++i){
cout<<"Tree "<<numTree[i]<<" has "<<nuts.nuts_left<<" nuts left"<<endl;
}
for(int i=0;i<=numSq;++i){
cout<<"Squirrel "<<numSq[i]<<" is at Tree "<<squirrel.location;
squirrel.location+=skipFactor;
}
}
int numSq[];
...
cout<<"Please enter the number of squirrels: "<<endl;
cin>>numSq;
for(int i=0;i<=numSq;++i){
numSq[i];
}
numSq is a pointer to an int, and then you write directly into that, changing its value to some location (which you also intend to be the number of squirrels, which is absolutely insane), then you loop based on the value of that pointer and all you do in the loop is nothing?
The program crashes. Doesn't give any errors unless you press cancel while it is compiling. Compiler doesn't finish itself. Its like it gets caught in a loop.
int numSq; // This is just an int.
cout<<"Please enter the number of squirrels: "<<endl;
cin>>numSq;
// Now need to make an array big enough for all the squirrels
int* squirrelArray = new Squirrel[numSq];
// Done. squirrelArray is the array of squirrels