Hello,
C++ is a rather new programming language to me, But I have been working with different languages which are making things slightly easier to me.
Nevertheless, I'm currently stuck on a (I believe) obvious issue which I myself don't recognize.
I'm getting an error saying:
"Error: Expression must have pointer-to-object type"
on these spots:
cin >> Numbers [NumIncrease]; //Manually Insert random numbers
cout << Numbers [NumIncrease] << " - "; //Display Inserted numbers (on one line)
Since I have no clue where the error might be; I'll just give the entire code. It's not too long anyway.
code:
NOTE, UPDATED VERSION IS IN LATER REPLY!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
//Include files
#include <iostream>
#include <string>
#include "conio.h"
using namespace std;
//Main Program
void main()
{
//Set Initials
system("color 0f");
int LimitMin, LimitMax, Counter, Amount, Numbers, NumIncrease;
//Set values to initials (not sure if C++ requires, but anyway - just in case)
LimitMin = 0 ;
LimitMax = 100 ;
Amount = 0 ;
Counter = 0 ;
Numbers = 0 ;
NumIncrease = 0 ;
//Start Introduction
cout << endl;
cout << endl;
cout << "______________" << endl;
cout << endl;
cout << "|Use of Arrays|" << endl;
cout << "______________" << endl;
cout << endl;
cout << endl;
cout << "How many numbers do you want to insert? (<100)" << endl;
//Start amount of numbers inserting test
Testamount:
cin >> Amount;
if (Amount >= LimitMin && Amount <= LimitMax) //amount accepted
{
cout << endl;
NumIncrease=0;
//Starting the number input
Startcount:
if (NumIncrease <= Amount)
{
cout << "Number " << NumIncrease << ": ";
cin >> Numbers [NumIncrease]; //Manually Insert random numbers
cout << endl;
NumIncrease +=1;
goto Startcount;
}
else //if finished inserting numbers
{
cout << endl;
cout << endl;
cout << "Inserted Numbers: " << endl;
cout << endl;
NumIncrease=0;
//Draw Inserted Numbers
Draw:
if (NumIncrease <= Amount)
{
cout << Numbers [NumIncrease] << " - "; //Display Inserted numbers (on one line)
//goto Draw;
}
else
{
cout << "Blehh, program finished for so far"; //Will continue with real code when error is solved!
goto Endprogram;
}
}
}
else //if too many numbers inserted
{
cout << endl << "The number you chose is not allowed! it has to be between 0 and 100." << endl << "Try Again: ";
goto Testamount;
}
Endprogram:
//Pause Program and return basic colors
system("pause");
system("color 08");
}
|
PS. The point of it is that the program requests for a certain amount of numbers (between 0 and 100), each number (sort of id) will get a number linked to it. then at first, these numbers will all be written out and eventually another line that cancels out the numbers that have been used multiple times.
eg. insert amount = 5
number1=10
number2=29
number3=10
number4=29
number5=4
first it should draw the numbers:
10 - 29 - 10 - 29 - 4
and then cancel out the ones that have been used multiple times
10 - 29 - 4
I Hope I've put this post in the right place. My apologies if not!
Thanks in advance!