0

I am working with a project but I can't seem to read from a file to a double. Please help me.

This is my code:

std::ifstream loadFile1("voltagelevel.txt"); if (loadFile1) {

while (loadFile1&&loop<20)
{ 
loadFile1 >> voltagelevel[loop];
textprintf_ex(screen, font, 50, 100+(loop*10), makecol(255,0,0),-1, "%ld", voltagelevel[loop]);
loop++;
} 
loadFile1.close(); }

1 Answers1

0

The allegro textprintf arguments are incorrect. I assume that you want a long double, in that case change it to %Lf or if you want just a double, %f

textprintf_ex(screen, font, 50, 100+(loop*10), makecol(255,0,0),-1, "%Lf", voltagelevel[loop]);

textprintf_ex(screen, font, 50, 100+(loop*10), makecol(255,0,0),-1, "%f", voltagelevel[loop]);

Also, the default font is an 8x8 size but it's not required to space it evenly.

Casey
  • 10,297
  • 11
  • 59
  • 88