there is no such index value as company[15], the indices are numbered 0, 1, 2, ... 14. A safer loop is to use integer, not pointer, in the for statement. Attempting to use ptr like you did is not safe because it depends on how the computer's memory is laid out
for(int i = 0, ptr = company; i < 15; i++, ptr++)
{
|
Finally, declare a const int to represent the number of elements in company so that you can easily change its value whenever you wish with little effort.