?
Solved

keep numbers after sign

Posted on 2007-11-27
1
Medium Priority
?
196 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 500 total points
ID: 20362428
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!

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

770 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