I am having trouble implementing a type def in a header file and using the same typedef in a source file (.c). Any help would be appreciated.

Also, I can't get a sum function to work, for when i want to sum the numbers pressed on a keypad( i would like to use numerics as my typedef). the numerics only returns a float number.

my code

float sum (void)
{
if(sum<=1)
{
sum = sum + numerics;
lcd_print_float (sum);
else(sum=numerics-1)
{
lcd_print_float(sum)
}
}

any help is greatly appreciated thanks!

Use [CODE] tags.

float sum (void)
{
    if(sum<=1)
    {
        sum = sum + numerics;
        lcd_print_float (sum);
        else(sum=numerics-1)
        {
            lcd_print_float(sum)
        }
    }
}

Probably not what you wanted, eh? Maybe you meant something like this:

float sum (void)
{
    if(sum<=1)
    {
        sum = sum + numerics;
        lcd_print_float (sum);
    }
    else
    {
        sum = numerics-1;
        lcd_print_float(sum);
    }

    return something;
}

I think there are several things wrong with that code . . . .

Also, I can't get a sum function to work, for when i want to sum the numbers pressed on a keypad

What input function are you using? Regular cin/scanf would require some extra work to do that.

What is the typedef supposed to do?

You need to provide more information.

I figured it out. The code was for a vending machine, and the sum hepled add the amount deposited. Thanks for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.