The code below is crashing with EXC_BAD_ACCESS. Anyone have any clues as to why?
The following warnings are reported:
Incompatible integer to pointer conversion assigning to ‘char *’ from ‘int’
register int t;
char *s;
double val;
s = printn(val);
t = strlen(s); // <<< breaks on this line
...
char *printn(n)
double n;
{
register char *fmt, *s, *ss;
double absn;
short sign;
....
s = printb("%-0.2f", sign*absn);
for (ss = s; *ss; ++ss);
while (*--ss == '0' || *ss == ' ') *ss = 0;
if (*ss == '.') *ss = 0;
return(s);
}
Thank you.
At this point, no declaration of
printnis in scope. So the compiler, using the old C89 rules, assumes an implcit declaration ofprintnreturning anint.Declare all functions before you use them.
That would work.
Please use the modern syntax,