• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

keep numbers after sign

hello there,
I have this chars in here but instead of keeping the numbers I would like to keep the letters
the c++ source code is working fine I just would like to change it..

32423=wresdf
54456=uiohjk
567567567=cvbfgyhj
657567=sdfyui
6776=qwukij
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
 
int main (int argc, char** argv)  {
 
    if (argc != 3) {
 
        cout << "Usage: program  <infile> <outfile>" << endl;
 
        return 0;
    }
 
    ifstream is;
    ofstream os;
 
    is.open(argv[1]);
 
    if (!is.is_open()) {
 
        cout << "Cannot open " << argv[1];
 
        return -1;
    }
 
    os.open(argv[2]);
 
    if (!os.is_open()) {
 
        cout << "Cannot open " << argv[2];
 
        return -1;
    }
 
    while(!is.eof()) {
 
        string str;
 
        getline(is,str);
 
        int pos = str.find('=');
 
        if (-1 != pos) str.erase(pos,str.length() - pos);
 
        os << str << endl; // line feed was missing
    }
 
    return 0;
}

Open in new window

0
Woodie2986
Asked:
Woodie2986
1 Solution
 
UrosVidojevicCommented:
if (-1 != pos) str.erase(pos,str.length() - pos);

->

if (-1 != pos) str.erase(0, pos+1);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now