|
From: Wobien <wo...@pl...> - 2002-11-18 12:40:36
|
You must declare variable as a pointer so that you can later make point to
an array with the dimensions y wish.
When you are finished with the array you destroy it with the delete
statement to free the memory it uses.
#include <iostream.h>
int main()
{
int number;
int incrementer;
int *variable;
cout << "please enter the number of sheetlengths needed" <<endl ;
cin >> number;
variable = new int[number];
incrementer = 0;
while (incrementer < number)
{
cin >> variable[incrementer];
incrementer ++ ;
}
delete [] variable;
return 0;}
----- Original Message -----
From: Steele Baldock
To: dev...@li...
Sent: Monday, November 18, 2002 8:22 AM
Subject: [Dev-C++] Help for a newbie
Hi all
I am looking for a structure to put into a probgram I am writing to
calculate the materials needed for a roof. I need a structure that will
generate the variables needed based on an input (int) from the user.
Something like this:
cout << "plese enter the number of sheetlengths needed" <<endl
cin >> number
incrementer = 0
while (incrementer < number)
{
int variable(incrementer)
int variable(incrementer)
incrementer ++
}
So I need variables that are numbered sequencially so I can get the user to
input them.
Any other ways of tackling this problem would be helpful too.
Thanks all
Steele Baldock
ba...@wx...
|