Solved

keep numbers after sign

Posted on 2007-11-27
1
189 Views
Last Modified: 2010-04-01
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
Comment
Question by:Woodie2986
1 Comment
 
LVL 7

Accepted Solution

by:
UrosVidojevic earned 125 total points
ID: 20362428
if (-1 != pos) str.erase(pos,str.length() - pos);

->

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now