Faced such a problem, I can not find how to solve it. The program asks to enter the name of the file to search for it on the disk. But the fact is that you have to enter the full path to the file, for example "C: \ PRIMER.txt".
Question: how to add a program so that you do not need to enter the full path, but only "PRIMER".
#include <iostream> // std::cout, std::cin #include <fstream> // std::ifstream #include <clocale> // setlocale( LC_ALL, "Rus" ); #include <cstdlib> // system( "pause" ); int main(int argc, char * argv[]) { setlocale(LC_ALL, "Rus"); char file_name[24]; std::cout << "Введите имя файла: "; std::cin >> file_name; std::ifstream file; do { std::cout << "\nФайл не найден.\n" << "Введите имя файла: "; std::cin >> file_name; file.open(file_name); if (file.good()) break; } while (true); char strBuff[124][124]; int n_strok = 0; std::cout << "\n"; while (!file.eof()) { file.getline(strBuff[n_strok], sizeof(strBuff[n_strok])); std::cout << n_strok + 1 << " " << strBuff[n_strok] << "\n"; ++n_strok; } std::cout << "\n"; system("pause"); return 0; }