Original Post
Im doing a part in my C++ book about pointers and arrays and this is the example from the book. When I compile and run it it only shows Array of integers 98 at 2359120 -486 at 2359124 301589 at 2359128 Array of chars: Array of doubles: ------------------------------------------------------- Here is the code, what is wrong with it?
[source lang ="cpp"]
#include <iostream>
int main(){
const unsigned short ITEMS = 3;
int intArray[ITEMS] = {98,-486,301589};
char charArray[ITEMS] = {'A','B','C'};
double doubleArray[ITEMS] = {3.14315614, 2.74546944, 7.349e14};
int *intPtr = intArray;
char *charPtr = charArray;
double *doublePtr = doubleArray;
std::cout<<"Array of integers:\n";
for (int i; i < ITEMS; ++i){
std::cout<< *intPtr <<" at "<< reinterpret_cast<unsigned long>(intPtr)<<"\n";
intPtr++;
}
std::cout<<"\nArray of chars:\n";
for (int i; i< ITEMS; ++i){
std::cout<< *charPtr <<" at "<< reinterpret_cast<unsigned long>(charPtr)<<"\n";
charPtr++;
}
std::cout<<"\nArray of doubles:\n";
for (int i; i< ITEMS; ++i){
std::cout<< *doublePtr <<" at "<< reinterpret_cast<unsigned long>(doublePtr)<<"\n";
doublePtr++;
}
std::cin.get();
return 0;
}