i think thats correct , but codeblocks keep telling me thats not :
1 2 3 4 5 6 7
|
string * module;
module = new string[7];
for(i=1;i<8;i++)
{
cout<<"\nentrer le module numero : "<<i<<endl;
cin>>module[i];
}
|
Last edited on
C or C++ are start from "0" not "1"
1 2 3 4 5 6 7 8
|
string* module = new string[7];
//try....
for(size_t i = 0; i < 7; ++i)
{
cin>>module[i];
}
delete []module;
|
besides, why do you use new but not vector?
1 2 3 4 5
|
vector<string> module(7);
for(size_t i = 0; i < 7; ++i)
{
cin>>module[i];
}
|
Last edited on
array of 7 elements has elements from 0 to 6.
ty so much my friends
@stereoMatching : whats the diffrence betwwen "new" and "vector" ??
vector will take care of reallocating (should you ever need to change its size) and deallocating your array.
Last edited on