A89: C problem


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

A89: C problem



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



void _main(void)
{


int n,string[100],num=0,count,handle;
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)
        {
        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));
        if(0!=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;
        }
        // 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;
        }
        }
}

#include <nostub.h>
#include <timath.h>
#include <estack.h>
#include <string.h>
#include <alloc.h>
#include <args.h>
#define RETURN_VALUE

int_ti89



void _main(void)
{


int n,a=0,mats[100],num=0,count,handle;
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)
        {
        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));
        if(0!=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(mats[count]);
        }
        push_LIST_TAG();
        return;
        }
        // b
        }
        
        ++num;
        mats[num]=trunc(a_ti);
        if(trunc(a_ti)!=trunc(b_ti))
        {
        ++num;
        mats[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(mats[count]);
        }
        push_LIST_TAG();
        return;
        }
        }
}


Follow-Ups: