Help with programming


#1

I recently installed the Ubuntu subsystem onto win10. It isn’t full-featured or up-to-date, so I have to install and build software, which I don’t like due to the lack of experience and talent. I feel like I am thrashing in the dark, brute forcing my way until something happens. Very time consuming.

Anyway, I have decided to make a thread where I shall ask questions from time to time. Others may do so as well. :wink: Not all of us are pros, right?


First question:
Several years ago, I hacked a *.cpp file to save an image. I know nothing about c++ but found something that worked using boost’s filesystem. Now it doesn’t (due to a different version?).

// AFRE CODE → SAVE RESULTS
path p{argv[i]};
path sdir{p.parent_path().string() + "/DET/" + p.stem().string() + ".png"};
path d{p.parent_path().string() + "/DET/"};
cout << p.filename().string() << '\n' << endl;
create_directory(d);
if (tile_images(chips).size() != 0)
{
    save_png(tile_images(chips), sdir.string());
}
else
{
    save_png(img, sdir.string());
}

My intention is to create a new sub-directory where the output files would go. Currently, it is trying to save to /DET/ (at root) instead. What should I do? Should I even be using boost?


(Gord) #2

This line:

suggests that a path name is supposed to be passed to the program as an argument. Not knowing the value of i it’s not possible to say which of possibly several arguments it is. It would help if you showed the entire program.


#3

I am here: /mnt/x/_px.   argv[i] is the input file at /mnt/x/_px/input.png.   Saving to /DET/output.png instead of /mnt/x/_px/DET/output.png

I know what the problem is now. I didn’t type “./” before output.png. In win10, I don’t have to do that.