One way to list files is through functions FindFirstFile and FindNextFile (Windows):
#include <windows.h> /* Para usar as funções de busca de arquivos */
#include <vector>    /* Para usar */
#include <sstream>   /* Para usar o Stringstream */
#include <iostream>  /* Para manipular a entrada/saída de streams */
#include <fstream>   /* Para usar o ifstream */
....
using namespace std;
...
vector<string> ProcurarArquivos(string diretorio) {
    vector<string> arquivos;                      /* Vetor que irá armazenar os resultados temporários */
    string busca = diretorio + "\\*.txt";         /* Cria o filtro, no diretório será encontrado somente arquivos .txt */
    HANDLE hFind;                                 /* Identificador da pesquisa */
    WIN32_FIND_DATA data;                         /* Estrutura que conterá informações dos arquivos */
    hFind = FindFirstFile(busca.c_str(), &data);  /* Procura pelo primeiro arquivo */
    if (hFind != INVALID_HANDLE_VALUE) {          /* Se a função não falhar */
        do {
            arquivos.push_back(data.cFileName);   /* Armazena no vetor o nome do arquivo encontrado */
        } while (FindNextFile(hFind, &data));     /* Procura pelo próximo arquivo */
    FindClose(hFind);                             /* Fecha o identificador da pesquisa */
    }
    return arquivos;                              /* Retorna o vetor como resultado */
}
To read the contents of the file and return in a string, do:
string LerAquivo(string arquivo) {
    ifstream ifs;                                          /* Stream usada para fazer operações em arquivos */
    ifs.exceptions (ifstream::failbit | ifstream::badbit); /* Define quais exceções podem ser lançadas */
    try {                                                  /* Tenta executar o código abaixo */
        ifs.open(arquivo.c_str());                         /* Abre o arquivo */
        stringstream ss;                                   /* Stringstream que vai conter o resultado */
        ss << ifs.rdbuf();                                 /* Lê o buffer do stream e coloca no Stringstream */
        string str = ss.str();                             /* Coloca numa string o resultado do Stringstream */
        return str;                                        /* Retorna a string */
    }
    catch (ifstream::failure e) {                          /* Se houver erros em relação a leitura dos arquivos */
                                                           /* Fazer alguma coisa aqui caso ocorram erros */
        return "";                                         /* Retorna uma string vazia */
    }
}
To get the application path use the function GetModuleFileName:
string DiretorioDaAplicacao() {
    char buffer[MAX_PATH];                        /* Cria um buffer com tamanho máximo para um diretório */
    GetModuleFileName(NULL, buffer, MAX_PATH);    /* Para retornar o caminho completo do executável */
    int pos = string(buffer).find_last_of("\\/"); /* Captura a posição da última barra "/" */
    return string(buffer).substr(0, pos);         /* Extraí tudo desde o início até o ponto onde foi encontrado a barra "/" */
}
To extract only the file name, use the function:
string ExtrairNomeDoArquivo(string caminho) {
    int indice = caminho.rfind('/');              /* Encontra o índice da última ocorrência da barra "/" */
    return caminho.substr(indice + 1);            /* Extraí tudo a partir do índice da barra "/" */
}
Note: Works only on Windows, and there are times when this function may fail.
Example of use:
int main() {
    string Diretorio = DiretorioDaAplicacao();             /* Captura o diretório da aplicação */
    vector<string> arquivos = ProcurarArquivos(Diretorio); /* Cria um vetor que armazenará os o caminho dos arquivos encontrados */
    for (vector<string>::iterator i = arquivos.begin(); i != arquivos.end(); i++) { /* Faz a iteração sobre o vetor "arquivos" */
            string conteudo = LerAquivo(*i);               /* Coloca na variável o conteúdo do arquivo atual da iteração */
            string arquivo  = ExtrairNomeDoArquivo(*i);    /* Coloca na variável somente o nome do arquivo atual da iteração */
            cout << "Nome do arquivo: " << arquivo << endl;
            cout << conteudo << endl;
    }
    cin.get(); /* Espera o usuário digitar algo*/
    return 0;  /* Termina o programa */
}
							
							
						 
These files will be in the same folder as the executable?
– stderr
yes, or it would be better to create a folder there even with that files?
– Vale
It will depend on what you want, but as a matter of organization, having a proper directory for these files should be more suitable.
– stderr
fully agree .
– Vale
It is not very clear in your question what the real problem is. Why simply do
ifstream Arquivo1, Arquivo2; Arquivo1.open("teste.txt"); Arquivo2.open("teste2.txt");doesn’t fit? Did you mean that you don’t know how to find the next file/list files in a folder (something like this SOEN question: http://stackoverflow.com/questions/612097/how-can-i-get-the-list-of-files-in-a-directory-using-c-or-c)?– Luiz Vieira
@Luizvieira can only have or no more two file, the user plays five file, so it has to be something generic to read the txt files
– Vale
But the problem is not reading the files, but rather listing them for the read function, right?
– Luiz Vieira
@Luizvieira really , when reading one he will check if he has another file, if he has it he will read this file, and so on.
– Vale
Okay, then edit the question to make it clearer. :)
– Luiz Vieira