output is not as expected it should print 12 not 102

  c++, string

output should be 12 not 102 why is it not deleting all the zeros

#include<bits/stdc++.h>

using namespace std;

int main()
{
    string s="10002";
    for(int i=0;i<s.size();i++)
    if(s[i]=='0')
    s.erase(s.begin()+i);
    cout<<s;
}

Source: Windows Questions C++

LEAVE A COMMENT