Find if a shell file exists
Here is my C++ file:
using namespace std;
cout << "rentrez nom du shell\n";//give me the name of the shell
string shell("");//empty string
cin >> shell;
cout << total <<endl;// Ok jusque là
ifstream monFlux("/home/sylvain/essai"); //On essaye d'ouvrir le fichier
if(monFlux) cout << "Ce fichier existe\n";
else cout << "fichier inexistant." << endl;
Impossible to replace (in the ifstream line) what is in the parenthesis by the string "total". What shall i do if I want that the above file works well , with a whatever shell file ? Many thanks for your answer.
Why this line:
@jsulm I thought it was possible to put that inside the parenthesis of ifstream. Now i Think it is impossile. I cannot introduce introduce a string in the middle of a program line. Isnt'it ?
It does not make any sense to add " to a string containing a path - it will become invalid path! Because " is not allowed in paths.
If you want the path to be enclosed in " if you print it out then do:
cout << '"' << total << '"' <<endl;
This one I don't understand:
I cannot introduce introduce a string in the middle of a program line. Isnt'it ?
What do you mean?