cout << a << endl; will output the address of the array a, this is likely not what you wanted. To output an array you can use std::copy like so
std::copy(vints.begin(),vints.end(),std::ostream_i terator<int>(std::cout," "));
where vints is a vector<int>, to do the same thing for an array we note that a pointer to an array is a random access iterator.
std::copy(a,&a[sizeof(a)/sizeof(a[0])],std::ostream_iterator<int>(std::cout," "));
Here we have a pointer to the start of the array and a pointer one past the end. Note that this will NOT work for a dynamically allocated array. You need to keep track of the size yourself and ether pass a pointer to a+size or use copy_n and pass the size as a paramiter.
I usually like to keep something like this around
Code:
template<class InputIterator>
bool write_csv(InputIterator ii, InputIterator end, std::ostream &os=std::cout) {
os << '{';
if(ii != end) {
os << *ii;
while(++ii != end) os << ", " << *ii;
}
os << '}';
return os.good();
}
template<class Container>
bool write_csv(const Container &c, std::ostream &os=std::cout) {
return write_csv(c.begin(),c.end(),os);
}
This provides nicely formated comma seperated values for any container, container-like structure, or anything I can get a pair of iterators out of. Finally if you intend to go through every permutation of a 100 element array I Really want to know where you buy your computers.