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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

825 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