Mail Archives: djgpp/2001/11/19/11:19:15
Ladislav Dvo??k <dvorakl AT jednotacb DOT cz> wrote:
> Hi,
> I have a application. When I run this application in Windows 95 or in DOS
> (with cwsdpmi.exe), he works without problem. When I this application run on
> barcode scanner Falcon 330 with ROM-DOS 6.22 and AMD Elan AM486 processor I
> have this problem.
> long vyhledzbo(char ean[20])
> {
> FILE *ciselnik;
> int vpom,pozmez,prv,pzaznamu,pruchodu=18;
> long kurszmm,kurszm,vpozice;
> char cean[20];
> float krok;
> int delkavety = 102;
> ciselnik = fopen("expean.txt","r");
> fseek (ciselnik,-delkavety,SEEK_END);
I suspect the error happens here, already. Note that you opened the
file in text mode, and then used fseek in SEEK_END mode on it, with a
nonzero offset. That's not guaranteed to do anything useful at all.
It'd probably be better if you opened that file in binary mode.
> pzaznamu = (ftell(ciselnik) / delkavety) + 1;
> krok = pzaznamu / 2;
> On line >krok=pzaznamu /2;< program crashed.
How exactly did it crash, and how certain are you that it was *this*
particular line? If you have a crash dump, please show it.
My guess would be that it's not this line, but the one above it that's
going wrong. Int->float conversion should always be safe, whereas the
conversion from long to int involved in your calculation of pzaznamu
may or may not.
BTW: you *did* #include <stdio.h> somewhere before this snippet, I hope?
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -