Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

keep numbers after sign

Posted on 2007-11-27
1
Medium Priority
?
199 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

604 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