hi, im new to this milist, i'm trying to learn c++ as we speak, i'm 
still beginner, i'm kinda stuck with my code, see if you could explain 
to me why, here's the code :

int sum(int, vector<int>);

int main()
{
     vector<int> nums;
     int a=0, b=0;
     cout<< "Please enter some number! Enter | to stop!"<<endl;
     while(cin>>a){
         if(a=='|') break;
         nums.push_back(a);
     }

     cout<<"Please enter how many number do you wanna sum"<<endl;
     cin>>b;
     try{
         cout<<"Sum of "<<b<<" number is "<<sum(b, nums)<<endl;
     }catch(exception& e){
         cerr<<e.what()<<endl;
     }
     return 0;

the problem is the 2nd cin, doesn't wait for me to input anything, it 
just went through, can you explain to me why? what did i do wrong? is it 
save to use "break"? sorry i'm coming from java background so please 
help me, thanks before hand :)

CK

Reply via email to