im looking to brush up on my C++ coding as its been a quite a few months since ive done anything with it and ive run into a snag with my coding and have spent hours with 2 Compilers (Bloodshed Dev C++ (where code was originally written)as well as Eclipse IDE) to no avail.
#include <iostream>
#include <ctime>
using namespace std;
int rn[20];
int counter3;
int *largestrandom;
int tempNum, counter1, counter2;
int main ()
{//int-main start
srand((unsigned)time(0));//random seed
for (counter3 = 0;counter3 < 20; counter3++)
{//random numbers start
rn[counter3] = rand() % 100 + 1;
}//random numbers end
//first loop lets you go by rows and sorts
for (int counter1=0; counter1<20; counter1++){
//second loop allows you to go left to right and sort
for(int counter2=0; counter2<20; counter2++){
//see if the number on the left is bigger than on the right
if(rn[counter2]>rn[counter2+1]){
//if it is then swap them using a temporary holder
tempNum=rn[counter2];
rn[counter2]=rn[counter2+1];
rn[counter2+1]=tempNum;
}
}
}
for (counter3 = 0;counter3 < 20; counter3++)
{//random numbers start
cout << rn[counter3] << endl;
}
cout << "\nand the largest number is " << rn[19];
tempNum = rn[19];
largestrandom = &tempNum;
cout << " Stored at location " << largestrandom << endl ;
system ("pause")
return 0;
}//int-main end
i seem to keep getting these errors:
Function 'system' could not be resolved (i only got this one from eclipse IDE using mini GW C++ compiler plugin/addon)
'rand' was not declared in this scope
'srand' was not declared in this scope
Function 'srand' could not be resolved
Function 'rand' could not be resolved
The weird part about this is that this code worked about 3-4 months ago the last time i ran it. and even when i substituted a simple random number output program instead the compilers still seemed to give me the same errors. Any help would be appreciated and i apologize in advance as i know this is going to be a very simple mistake on my part.