Re: A89: C problem


[Prev][Next][Index][Thread]

Re: A89: C problem




Attack of the big bad C GURU!


JHill8075@aol.com wrote:
> 
> I wrote this program (below my name) to calculate all the factors of a
> number. When I try to compile it, I get a ton of errors. Most of the ones
> that are visible on the screen (the rest scroll off) say error on line 62,
> but some of the symbols that it's complaining about don't even exist on line
> 62! Can someone please look at my code and tell me what's wrong with it. This
> is my first C program, so they're probably just stupid errors, but I can't
> seem to find anything wrong with it (I think it might have to do with the
> conversion from TI_FLOAT to INT). Thanks.
> 
>         Josh
>         <A HREF="http://pa.ticalc.org">Programmers Anonymous</A> Member
> 
> #include <nostub.h>
> #include <timath.h>
> #include <estack.h>
> #include <string.h>
> #include <alloc.h>
> #include <args.h>
> #define RETURN_VALUE
> 
> int _ti89

you need a semi-colon...
	int _ti89;

> 
> void _main(void)

this should be:
	void main(void)

> {
> 
> int n,string[100],num=0,count,handle;
why are you declaring an array of 100 integers and calling it string?
use this:
	char string[100];

> float b;
> ti_float b_ti,a_ti=flt(1),n_ti;
> 
> char fpart_string[100];
> ESI argptr=top_estack;
> n=GetIntArg(argptr);
> n_ti=flt(n);
> 
>         while(1==1)
You sure you want to do this?
>         {
>         b_ti=fdiv(n_ti,a_ti);
>         sprintf(fpart_string, "FPart(%f)", b_ti);
>         push_parse_text(fpart_string);
>         NG_rationalESI(top_estack);
>         handle=display_statements(top_estack,1,1);
>         b_ti=flt((float)HeapDeref(handle));

As for the workings of your algorythm... that's -your- problem :)
I'm just a language guy

>         if(0!=trunc(b_ti))
>         {
Suggestion: Indentation is good. Very good.
You will worship indentation.

> 
>         // b
>         a_ti=flt(trunc(a_ti)+1);
>         if(trunc(a_ti)>trunc(floor(sqrt(n_ti))))
>         {
>         push_END_TAG(void);
>          for(count=num,count==1,count=count-1)
icky poo!
you want:
	for(count=num;count!=1;count--)

>         {
>                 push_longint(string[count]);
>         }
>         push_LIST_TAG();
>         return;
>         }
>         // b
>         }
> 
>         ++num;
>         string[num]=trunc(a_ti);
>         if(trunc(a_ti)!=trunc(b_ti))
>         {
>         ++num;
>         string[num]=trunc(b_ti);
>         }
>         // b
>         a_ti=flt(trunc(a_ti)+1);
>         if(trunc (a_ti) > trunc(floor(sqrt(n_ti))))
>         {
>         push_END_TAG(void);
>         for(count=num,count==1,count=count-1)
>         {
>                 push_longint(string[count]);
>         }
>         push_LIST_TAG();
>         return;
>         }
>         }
> }
> 

I hope that was some help to you
--robin



References: