0
Unsure about using arrays
Here's the code: int x = 0; int registeredStudents [10]; while (x<10) { cout << "Student #" << x+1<< ":"; cin >> registeredStudents [x] >> endl; x++; } I'll trying to insert separate names into each of the slots inside of the registeredStudents array based on x, but I keep getting a generous with pop onto my computer about the cin >> line of code. Any help appreciated.
4 Answers
+ 2
You don't need endl after cin. You use it in cout as an alternative.
https://www.sololearn.com/learn/CPlusPlus/1604/
+ 1
Erm is the data a string or is it a number ?
+ 1
My best advice, Don't often use arrays. Try and study the c++ standard template library (STL). There is what is called vector. It is quite better than arrays because it is dynamic and a lot of functions were added to it to make computing complex problems easier.
Thou, it has its down side. Array is quite faster than vector with few seconds.
NB: use Arrays when you know the amount of memory spaces that will be used. Use vectors when you don't know the amount of memory space that will be used up.
0
Leon lit yeah I'll fix that; there array type is supposed to be string. franky I understand your advice, however I was experimenting with arrays to practice my c++ knowledge, and I haven't really learned about vectors yet. I'm just wondering what's wrong with my program, or if it's even possible to take Julie inputs and put it into an array like I'm trying to do.