Solve VECTOR2 problem using for loop

My solution

I use for loop instead of do while loop to solve this problem,
here I share my code with you, guys

“”"
include <bits/stdc++.h>
using namespace std;

int main() {
vector v;
char x;

for (;;) {
    cin >> x;
    v.push_back(x);
    if (x == 'z') {
        break;
    }
}

cout << v.size() << endl;

}
“”"

My code

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

int main() {
    vector<char> v;
    char x;

    for (;;) {
        cin >> x;
        v.push_back(x);
        if (x == 'z') {
            break;
        }
    }

    cout << v.size() << endl;
}

Learning course: STLs in C++
Problem Link: CodeChef: Practical coding for everyone