keep numbers after sign

Posted on 2007-11-27
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..

#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;[1]);

    if (!is.is_open()) {

        cout << "Cannot open " << argv[1];

        return -1;


    if (!os.is_open()) {

        cout << "Cannot open " << argv[2];

        return -1;


    while(!is.eof()) {

        string 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

Question by:Woodie2986
1 Comment

Accepted Solution

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


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

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 (…
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