> Just wondering about vectors, they are all one after each other like an array.
Yes, a vector is specifically stored as an array internally. So you could pass it to functions that take arrays:
1 2 3 4
|
void myarrfn( const int a[], unsigned size );
...
vector<int> v;
myarrfn( &v[0], v.size() );
| |
> So if you use string that can change its size, isnt it possible that the string overwrites the next string in the vector?
No, a string is a container class. So the array is an array of objects. Modifying one object doesn't affect other objects.
> Duoas, if you're using *nix, why not just
For the same reason you shouldn't say
system("cls")
in Windows. It is resource heavy and a security leak.
For cross-platform homework solutions, I don't mind seeing
if (system( "cls" )) system( "clear" );
But still, you should only clear the screen if you _need_ to. That's very rare. Remember, clearing the screen in a typical console application is fairly anti-user-friendly.
Hope this helps.