60 636
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #38928 in C++ for nico

Question #38928
I'm new in C++ and have a question about how to use a variable (pathLed) that carries a path in the fs.open function? String seams not to work. If I use define pathLed "/sys/class/leds/beaglebone:green:usr0" it works, but I need a variable to sign different paths to pathLed. Thanks for the answer. Nico

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

string pathLed = "/sys/class/leds/beaglebone:green:usr0";

fs.open (pathLed "/trigger", std::fstream::out);
fs << "none";
fs.close();
Expert's answer
Dear customer, please try this:
fs.open (pathLed.c_str(), std::fstream::out);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions