Some of this code may seem foreign to you since I make 3ds homebrew programs for fun but it's essentially the same but with extra lines of code you can put in. I'm trying to read a file called about.txt in a separate folder. I made it work when I put it in the same folder but i lost that file and then my partner said he wanted it in Scratch3ds-master\assets\english\text and not in Scratch3ds-master\source I keep getting the error I coded in. I'm new to stack-overflow so this might be too much code but well here's the code:
#include <fstream>
#include <string>
#include <iostream>
int main()
{
// Initialize the services
gfxInitDefault();
consoleInit(GFX_TOP, NULL);
int version_major;
int version_minor;
int version_patch;
version_major = 0;
version_minor = 0;
version_patch = 2;
printf("This is the placeholder for Scratch3ds\n\n");
std::ifstream about_file;
about_file.open("../assets/english/text/about.txt");
if (about_file.fail())
{
std::cerr << "file has failed to load\n";
exit(1);
}
Chance are that you're using devkitpro packages. And chances are that the devkitpro team provide an equivalent of the NDS 'ARGV protocol' for 3DS programming. In which case, if you use
you should have the full path to your executable in
argv[0]ifargcis non-zero.https://devkitpro.org/wiki/Homebrew_Menu might help.
Your program has no a priori knowledge of what sort of arguments
main()should receive, and in your question, you're using a main function that receives no argument at all.Established standard for C/C++ programming is that
main()will receive an array of constant C strings (typically namedargvfor arguments values) and the number of valid entries in that array (typically namedargcfor count). If you replace your original code withthen you're able to tell whether you received argument by testing
argc > 0and you'll be able to get these arguments values withargv[i].With homebrew development, it is unlikely that you can pass arguments such as
--forceor--directory=/bootas on typical command-line tools, but there is one thing that is still useful: the very first entry inargvis supposed to be a full path for the running program. so you're welcome to tryand see what you get.