I want to write a program that gets an integer from an user eg. 5
The five should tell the program that 5 variables should be created. How would i approach this problem? must one use arrays? any input will be appreciated
I want to write a program that gets an integer from an user eg. 5
The five should tell the program that 5 variables should be created. How would i approach this problem? must one use arrays? any input will be appreciated
Thanks for the reply, but im a bit thick and rather new to c++. Can you give a quick explaination of whats going on??
`Who are YOU?' said the Caterpillar.
This was not an encouraging opening for a conversation. Alice replied, rather shyly, `I--I hardly know, sir, just at present-- at least I know who I WAS when I got up this morning, but I think I must have been changed several times since then.' - Lewis Caroll's Alice in Wonderland.
This new expression allocates i objects of type int from the free store and returns the address of that object. We use that address to initialize the pointer pi.Code:int i; cin>>i; //get input from user int *pi;//define a pointer to int pi = new int [i]; //new allocates memory. In this case, //new allocates memory for i objects of type int. //and pi points to the first elements of the allocated space.
http://faq.cprogramming.com/cgi-bin/...&id=1043284351
Last edited by Antigloss; 06-20-2005 at 04:30 AM.
I have a basic idea of pointers. Does it work the same as in c?
I wasnt to bad in c, but that was about 2 yrs ago.
`Who are YOU?' said the Caterpillar.
This was not an encouraging opening for a conversation. Alice replied, rather shyly, `I--I hardly know, sir, just at present-- at least I know who I WAS when I got up this morning, but I think I must have been changed several times since then.' - Lewis Caroll's Alice in Wonderland.