Lets say I get something like this in Linux / Bash:
./my_program <input_file.in
is there a way in my code to check the name of my input file?
something like this?
if (strcmp(in,"desired_input_file_name.in")) {
printf("success!!"\n);
}
There is no portable simple way. Piping via <
will redirect the contents of input_file.in
to the standard input of my_program
. Its the same as if you had typed the contents of the file. If you want to know the filename then you need to pass that, eg as command line argument:
./my_program input_file.in
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With