Need program searches numbers inside a txt and perfroms an opperation

Program that will search specific numbers from inside a txt,cut them,and ask me to put the name of the folder to put them in :

So the whole idea is about a program that will search inside the txt i will give whatever number starts with _ (Example : _10165,_09957 ),and with the results it will search the directory wich i give.Example C:\Id Boxes and tell me wich of the numbers that searched from the txt are not found in this folder as archives (other .txts).Then cut those that found and ask me to create a folder with them.

Unless there is a program out there in the internet space wich already does it??

For further details please,question me!
Any help,comments,ideas would be much appreciated
I don't know how it will help you. The program calculates a sum of all numbers in file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <sstream>
#include <fstream>
#include <string>
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    ifstream from(argv[1]);
    string line;
    int summa(0);
    while(getline(from, line))
    {
        stringstream str;
        str << line;
        int newValue(0);
        str >> newValue;
        summa += newValue;
    }
    cout << summa << "\n";
    return 0;
}


argv[1] is a file, which has only numbers. For example test.txt:
012
123
546
657345
78
78
Last edited on
First of all thanks for answering me!
Hmm i add it to the Visual C++ Express Edition but it says there are built errors :(

Btw the txt looks likes this:
41260084 0922900001 _00001
41080004 0922900002 _00002


I only want to count the number with the " _ " in front of them

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <sstream>
#include <fstream>
#include <string>
#include <iostream>
#include <vector>

using namespace std;

const char MARKER = '_';

int main(int argc, char* argv[])
{
    ifstream from(argv[1]);
    string line;
    char ch(0);
    bool flag = false;
    vector < int > numbers;
    while(from.get(ch))
    {
        if(ch == MARKER)
        {
            flag = true;
            continue;
        }
        if(flag == true)
        {
            line += ch;
        }
        if((!(ch >= '0' ) && (ch <= '9')) && flag)
        {
            stringstream str;
            str << line;
            int newValue(0);
            str >> newValue;
            numbers.push_back(newValue);
            line = "";
            str.flush();
            flag = false;
        }
    }
    for(size_t i = 0; i < numbers.size(); ++i)
    {
        cout << numbers[i] << "\n";
    }
    return 0;
}


I've tested on the floowing file:
sjdkghk _1234cjkhvj _123
_43578 jsdka _78436 gvk
Last edited on
Topic archived. No new replies allowed.