mardi 28 avril 2020

how to read a whole vector?

#include"std_lib_facilities.h"
int main()
{
  vector<int>test = {1,2,3,4,5,6,7,8,9};
    cout<<test[0,8]<<'\n';
}

I want this code to print from 0 to 9 but it is only printing 9 and I also tried

cout<<test[0,test.size()] 

but it is showing an "range error 9".... Also please don't recommend me this code:

for(int x : test)
  cout<<x<<'\n';

because I don't know how to use that x effectively....please help me this...

Aucun commentaire:

Enregistrer un commentaire