Homebrew Discussion Read txt problem

  • Thread starter Thread starter jonyluke
  • Start date Start date
  • Views Views 1,265
  • Replies Replies 3

jonyluke

Well-Known Member
Member
Joined
Aug 22, 2018
Messages
145
Reaction score
115
Trophies
0
Age
27
XP
1,297
Country
Spain
I am working in a project,but i am having problems reading a txt file


dir = opendir("");
FILE *f = fopen("attach.txt", "r");
char att[30];
char natt[30];
fgets(att, sizeof(att), f);
fgets(natt, sizeof(natt), f);
fclose(f);
playMp3(att);
playMp3(natt);


It does not sound, however when i put playMp3("ting.mp3"); it sounds, so the problem is about reading the txt file
 
Last edited by jonyluke,
Nooooo, nonononono
It does not sound, however when i put playMp3("ting.mp3"); it sounds, so the problem is about reading the txt file

That is not how troubleshooting works. All you know is that, if you hardcode the sound file, it works. You don't know the following:

  • is the textfile being read
  • is it being read correctly
  • What is being returned when you call fgets
To sum it up, you don't know quite a lot
 
Last edited by Geodomus,
Code:
man fgets
fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A terminating null byte ('\0') is stored after the last character in the buffer.
 
I am working on this project,but i am having problems reading a txt file
https://gbatemp.net/threads/slidenx-change-joycon-attach-detach-sound.521749/

dir = opendir("");
FILE *f = fopen("attach.txt", "r");
char att[30];
char natt[30];
fgets(att, sizeof(att), f);
fgets(natt, sizeof(natt), f);
fclose(f);
playMp3(att);
playMp3(natt);


It does not sound, however when i put playMp3("ting.mp3"); it sounds, so the problem is about reading the txt file
I found a solution, dir = opendir("sdmc:/");
 
  • Like
Reactions: hippy dave

Site & Scene News

Popular threads in this forum