Solved

keep numbers after sign

Posted on 2007-11-27
1
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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++.

734 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