Here if you compile this and you put the .exe and the input.txt file any where on you hard drive (And both .exe and input.txt are in the same folder) the .exe will still know where the input.txt is at because they are still in the same directory because of relative paths. = ]
Code:
#include <fstream>
#include <conio.h>
#include <iostream>
int main() {
std::ifstream file_buffer;
file_buffer.open("./input.txt", std::ios::in | std::ios::beg);
if(!file_buffer) {
std::cout << "Couldn't find/open file" << std::endl;
}
else
std::cout << "File Found" << std::endl;
while(!kbhit()) {
}
file_buffer.close();
file_buffer.clear();
return 0;
}
Edit: I added conio.h -> kbhit()