Have source for an old program that I need to compile using modern C compiler. It’s going berserk over this section:
/*
* print numbers for ticks
* convert number to 2 decimal places except fractions less than 0.005
* negative numbers ok
*/
printn(n)
double n;
{
register char *fmt, *s, *ss;
double absn;
short sign;
sign = n<0. ? -1 : 1;
absn = n<0. ? -n : n;
if (absn < 0.0000001) absn = 0.;
/* if less than 0.005 then dynamically change the format */
PPA[Phh*6)'sn < 0.005 && absn != 0.0) {
short dec = 2;
double nn = absn;
while (nn < 0.005) {
nn =* 10.;
dec++;
}
fmt = "%-0.2f";
fmt[4] = '0' + dec;
s = printb(fmt, sign*absn);
} else
s = printb("%-0.2f", sign*absn);
/* clean out trailing zeroes/blanks/decimal point */
for (ss = s; *ss; ++ss);
while (*--ss == '0' || *ss == ' ') *ss = 0;
if (*ss == '.') *ss = 0;
return(s);
}
Now I believe
PPA[Phh*6)'sn < 0.005 && absn != 0.0) {
perhaps due to some text conversion error should be:
if (n < 0.005 && absn != 0.0) {
but I’m also getting an “Indirection requires pointer operand (‘double’ invalid)” on:
nn =* 10.;
Any help would be greatly appreciated.
nn *= 10.will multiplynnby10nn = *10.will try to dereference10., which is invalid (being a double), like the error says.Regarding indirection , the first search engine hit says:
The unary indirection operator (*) dereferences a pointer; that is, it converts a pointer value to an l-value. The operand of the indirection operator must be a pointer to a type. The result of the indirection expression is the type from which the pointer type is derived
In your case, the operand in
10., a double.