From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: crashed when float = int / 2 Date: 19 Nov 2001 16:13:17 GMT Organization: Aachen University of Technology (RWTH) Lines: 41 Message-ID: <9tbb2t$i06$1@nets3.rz.RWTH-Aachen.DE> References: NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 1006186397 18438 137.226.32.75 (19 Nov 2001 16:13:17 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 19 Nov 2001 16:13:17 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Ladislav Dvo??k 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 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.