Am I explaining this concept correctly?

About allocating and deallocating memory.

Here:

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
#include <iostream>

using namespace std;

int main()
{

	int index, amountInput; // The user's number and amount values

	// Get the amount of spaces to hold for the player's allocated numbers
	cout << "How many numbers would you like to enter? : ";
	cin >> amountInput;

	int* allocatedStorage = new (nothrow) int [amountInput]; // Allocates enough space in memory for the amount entered

	// If the computer cannot allocate enough memory handle it
	if (allocatedStorage == NULL)
	{
		cout << "Cannot allocate enough memory!" << endl;
		return 0;
	}

	// Loop through the indexes of the allocated space for the user to place values for
	for (index = 0; index < amountInput; ++index)
	{
		cout << "Enter number: ";
		cin >> allocatedStorage[index];
	}

	cout << "Your number's are : ";

	// Print the values of all the storage space in the allocated reference
	for (index = 0; index < amountInput; ++index)
	{
		cout << allocatedStorage[index] << " ";
	}
	delete[] allocatedStorage; // Free the allocated memory after we are done with it so other processes can use it

	cout << endl;

	return 0;
}


Thank you for viewing my thread! Very appreciated.
Well, other than ending your loop comment with a preposition, it seems fine. Some comments I've seen in code gets way more cryptic.
This one?

// Print the values of all the storage space in the allocated reference
no, this one:

 
// Loop through the indexes of the allocated space for the user to place values for 


However, if you're wanting to learn English composition, you came to the wrong place.:)

My comment in the above post was meant to be humor and nothing else.
cout << I'm a beginner.This is my first message.Hoho!
Oh okay, thanks roberts :). I'll use indices next time then!
Topic archived. No new replies allowed.