Re: Linux printf funny



"Paul Burke" <trash@xxxxxxxxxx> wrote in message
news:54iq2sF216i72U1@xxxxxxxxxxxxxxxxxxxxx
Stef wrote:

Is this a win32 console application or an old DOS application?


It was W32 console, compiled with VC++6.


It does not sound like a windows/linux problem, but more like a
programming error. So please show us the code.


#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>

#include "WinTypes.h"
#include "ftd2xx.h"
#include "ADC.h"

int TareWeight = 0; // ADC reading at no- load
double ScaleFactor = 1.0; // Bridge scale factor

double ReadWeight(void)
{
char buff[100];
double fweight; // Float version of weight
int Weight; // Weight as returned by ADC

Weight= ADCConvert();

fweight= (double)(Weight - TareWeight) * ScaleFactor;
sprintf( buff, "%08x - %08x -> %9.3f", Weight, TareWeight, fweight);
MessageBox( 0,buff,"Conversion Result",0);
return fweight;
}


If I was a betting man (which I'm not) then I'd say ScaleFactor is being
corrupted somewhere else. Clearly TareWeight doesn't stay 0 either. So, what
changes them?

[snip]

Peter


.


Quantcast