Solved

keep numbers after sign

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

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

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…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

729 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