i always hear about arrays and it makes sence to me but whats a tipical use for them may i pleas see an example because i dont understand why they eaven exisit

Recommended Answers

All 6 Replies

Take a look at this link

ya but wouldnt u have to enter every piece of data individually wether they were conected or not in an array so whats the point of having them connected in the first place?

Are you in school? (let's assume you are for the moment) Do you have classmates? How many? And how many in the whole school? (let's use 1000)

Would you want to define a single variable for everyone's name, then another for address, city, current class, grades so far..... That's 1000 distinct variables for the name. Another 1000 for the addresses. Another 1000...

I wouldn't. But one variable for the name, one for the city, etc, as an array and you have all the students in the array and you can get the information easily from just a few variables.

o so is that how mail merge works? with arrays?

a ya its still me im just on another acount in case u thought that was weaird

>ya but wouldnt u have to enter every piece of data individually
No. You could use loops to fill in data, which would require very little code. Let me show you an example:

for (int i=0 ; i < ARRAY_LENGTH ; ++i) {
    cout << "Type in a number" << endl;
    cin >> array[i];
}

>whats the point of having them connected in the first place?
Mostly so that they're easy to modify with loops. Another good example is a char array:

char myString[] = "test";

Without arrays, you'd be coding that for a lot longer...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.