Добрый ... всем! Пытаюсь обработать бинарные файлы в каталоге bin в цикле. Первое что я сделал это в buf загнал название файла, потом соединил их с путем. Далее преобразовал в const char* и передал функции ifstream. Ниже код и описание проблемы.
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <ctime>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
using namespace std;
int main(int argc, const char ** argv)
{
        char buf[1024];
        FILE * ls;
        int result;
        int i;
        const char* fname;
        strcpy(buf,"ls ./Bin/");
        for (i=1; i < argc; i ++) {
                strcat (buf, argv[i]);
                strcat (buf, " ");
        }
        ls = popen(buf,"r");
        if(!ls){
                perror("popen");
                return 1;
        }
        while(fgets(buf, sizeof(buf), ls)) {
                std::string namefile = std::string("./Bin/") + buf;
                fname = namefile.c_str();
                ifstream instrm (fname, std::ios::binary);
                //printf ("%s\n", fname);
                signed short t[240000] = {0};
                instrm.read((char *)t, sizeof(t));      // чтение файла в массив
                instrm.close();                         // закрываем
                for(int i = 0; i < sizeof(t)/sizeof(*t); i++){   // цикл вывода массива
                        cout << t[i] << ' ';
                }
                cout << '\n';
        }
        result = pclose(ls);
        if(!WIFEXITED(result)) return 1;
        return 0;
}
Проблема в том что если я ставлю переменную
ifstream instrm (fname, std::ios::binary);
ifstream instrm ("./Bin/file.bin", std::ios::binary);





