Hello
why am I getting 6 outputs instead of just 5 from this code?
thanks
#include <iostream>
#include <string>
using namespace std;
int main(){
string a[]=
{
"blue", "green", "red", "black", "white"
};
for(int i=0; i< (sizeof(a)-1); ++i)
cout << "item [" << i << "]= " << a[i] << endl;
}
item [0]= blue
item [1]= green
item [2]= red
item [3]= black
item [4]= white
item [5]=
Program received signal SIGSEGV, Segmentation fault.
0x40095847 in std::operator<< <char, std::char_trait s<char>, std::allocator< char> > () from /usr/lib/libstdc++.so.5
(gdb)
Comment