Well you can' t declare an array like that. An array cannot have zero elements. (At the very least that should cause some funny runtime errors but I'm not sure about whether or not the compiler has issues with a 0-element array.)
You should write code like THIS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string test[1];
test[0] = "this is a test";
cout << test[0] << endl;
return 0;
}
You could also write it like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string test[1] = {"this is a test"};
cout << test[0] << endl;
return 0;
}
yea while array elements start at the zeroth element that doesn't mean when declaring you subtract one. for instance if you want 100 elements in your array you say int array[100]; which gives you elements from zeroth to ninetynineth 0-99.