Click here to Skip to main content
16,019,018 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The problem terminates before taking any input. What could be the possible reasons for that? I am very new to competitive programming. Currently, I am learning Vector in STl.

What I have tried:

#include<bits/stdc++.h>
using namespace std;

void printvec(vector<int> v)
{
    cout<<v.size()<<endl;
    for(int j=0;j<v.size();++j)
    {
        cout<<v[j]<<" ";
    }
    cout<<endl;
}
int main()
{
   
    int i;
    vector<int> v;
    cout<<"Enter Array"<<endl;
    for(i=0;i<4;++i)
    {
        int k;
        cin>>k;
        v.push_back(k);
        printvec(v);
    } 
    printvec(v);
    return 0;

}
Posted
Updated 22-Jun-22 20:00pm

1 solution

The program, tested on my Linux box, runs correctly: it takes the input and produces the output.
Check your execution environment.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900