Hello guys,
I'm new here and with C++ and i have a problem if you are kind to help me.
Me and my friend have created a small program that download yt videos and upload them on specified yt accounts entered by us, when i hit run it opens 50 console aplications(2 acc x 25 console aplication)and each console opens at 2 sec and it has a timmer(20 min) before another 50 console aplications open again over and over.
I am stuck here because i don't know how to autoclose those console aplication.
Sorry for my english.
here is the program and if you cand help i will be greatefull.

#include <iostream>
#include <string>
#include <fstream>
#include<Windows.h>
using namespace std;
int i=0;
string key,acc,url;
        ifstream keyxxx("keywordsxxx.txt");
        ifstream accxxx("accxxx.txt");
        ifstream urlsxxx("urlsxxx.txt");

int reset (int start)
{

    int n=20,j;

    ofstream acc_bun("accounts.txt");
        getline(accxxx,acc);
        acc_bun<<acc<<endl;
        acc_bun.close();    
        if(acc=="*end*")
        {
            keyxxx.close();
            accxxx.close();
            urlsxxx.close();
            return start;
        }
        //cout<<"start = "<<start<<endl;
        if (start!=0 && start%2==0)     //pt 2 acc
                                        //if(start!=0) pt un acc
        {
            cout<<"Sleep "<<n<<" min."<<endl;
            for(j=1;j<=n;j++)
            {
            //cout<<"Sleep 30 min"<<endl;

            Sleep(60000);
            cout<<"min ramase: "<<n-j<<endl;
            //system("pause");
            }
        }
        cout<<"acc: "<<acc<<endl;

    if(!urlsxxx.eof())
    {
    ofstream url_bun("urls.txt");
        getline(urlsxxx,url);
        url_bun<<url<<endl;
        cout<<"url: "<<url<<endl; 
        url_bun.close();
    }

        if(key=="+++++")
        {
            ofstream key_bun("keywords.txt");
            getline (keyxxx,key);
            key_bun<<key<<endl;
            if(key=="*end*")
            {
                keyxxx.clear();
                keyxxx.seekg (0, ios::beg);
                getline (keyxxx,key);
                key_bun<<key<<endl;
            }
            key_bun.close();

            if(key!="+++++")
            {
                //cout<<"key: "<<key<<endl;
                system("start uploader.exe");
                Sleep(2000);
            }
        }

    while(key!="+++++")
    {
    ofstream key_bun("keywords.txt");
    getline (keyxxx,key);
    key_bun<<key<<endl;
    key_bun.close();
        if(key!="+++++")
        {
        //cout<<"key: "<<key<<endl;
        system("start uploader.exe");
        Sleep(2000);
        }
    }

    i++;
    return reset (i);
}
    void main (void)
    {
        int k=reset(0);
    cout<<"Accounts done: "<<k<<endl;
    system("pause");
    }

I need only the code for closing old opened consoles.
Thanks
Alex

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.