arrays

if im saving input as arrays, how do i check to see if the user went over the size of the array?
hmm... that's very simple... the answer is actually in your question...


im saving input as arrays


of course the user's input is automatically fit to the array size, for example:

1
2
3
4
5
6
7
8
9
10
11
const int ARRAY_SIZE = 10;
int user_input [ARRAY_SIZE] = {};

for (int i = 0; i < ARRAY_SIZE; ++i) {
   std::cout << "enter number " << (i + 1);
   std::cin >> user_input [i];
}

std::cout << "and the result is: " << std::endl;

//for (blablabla) 


CMIIW
Please comment your code so i will know what everything does.
Last edited on
you do not understand a simple code ?
are you studying in diploma course or?

the code already explain all

try to use a paper to draw out and make yourself more clear about it
too many comments can actually hinder understanding, instead of helping as they cluttered up the code. If you make good variable names, code normally can explain itself.

You got that response because 1) your initial post did not contain any code that you attempted 2) because your second post made a request for comments, not specific, just for comments. Between the first 2 comments it gives off the impression that you are looking for a freebie to some class that you are at, and that you do not want to do the work. If that is the case i could expect another one of your 3rd posts, if not i could expect it to give your version of what you might think the code does, and the forum then can help fill in the gaps.

EDIT: the 3rd post that i forgot to quote that you deleted.
Last edited on
Topic archived. No new replies allowed.