Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: dschiller on May 01, 2009, 05:15:57 pm

Title: Begginer needs help with some (probably basic) errors
Post by: dschiller on May 01, 2009, 05:15:57 pm
Hi all  :D

I've just started programming in C, and I've been using CodeBlocks as my compiler. I'm currently writing a small program that does some not-terribly-useful stuff, and I've been getting the following errors:

C:\Documents and Settings\Administrator\Desktop\EP3.c|45|error: invalid conversion from `int' to `int*'|

The code in question is:

iverm = instrucao (&codigo, verm);

Which goes after the following function:

int instrucao (float *codigo, int n){

    int ins, i;
    ins = i = 0;

    i = (n)*(*codigo);
    ins = (int)i;
    *codigo = i - ins;

    return ins;
}

Any ideas about why this might be happening?

I've also been getting the following warnings:

C:\Documents and Settings\Administrator\Desktop\EP3.c|76|warning: int format, pointer arg (arg 2)|
C:\Documents and Settings\Administrator\Desktop\EP3.c|76|warning: double format, pointer arg (arg 3)|
C:\Documents and Settings\Administrator\Desktop\EP3.c|76|warning: int format, pointer arg (arg 4)|
C:\Documents and Settings\Administrator\Desktop\EP3.c|76|warning: double format, pointer arg (arg 5)|
C:\Documents and Settings\Administrator\Desktop\EP3.c|76|warning: double format, pointer arg (arg 6)|
C:\Documents and Settings\Administrator\Desktop\EP3.c|76|warning: int format, pointer arg (arg 7)|
C:\Documents and Settings\Administrator\Desktop\EP3.c|80|warning: double format, pointer arg (arg 2)|
C:\Documents and Settings\Administrator\Desktop\EP3.c|80|warning: double format, pointer arg (arg 3)|

Lines 76 and 80 are:

if (trace == 1) printf ("%d     %13.10f         %d      %13.10f         %13.10f         %d\n", &passo, &codigo, &iverm, &xant, &yant, &bat);

printf ("\nPosicao final: (    %13.10f,    %13.10f  )", &xant, &yant);

Again, any suggestions about why this is happening?

Finally, I've been getting this last warning:

C:\Documents and Settings\Administrator\Desktop\EP3.c||In function `int instrucao(float*, int)':|
C:\Documents and Settings\Administrator\Desktop\EP3.c|182|warning: converting to `int' from `float'|

Which seems to have something to do with the function "instrucao" posted above. Line 182 is:

i = (n)*(*codigo);

Thanks in advance for any input!

EDIT: The smiley after `int instrucao(float*, int)' is supposed to be ":" followed by "l".
Title: Re: Begginer needs help with some (probably basic) errors
Post by: TDragon on May 01, 2009, 07:18:36 pm
Sorry, but the Code::Blocks forums are only for issues related to Code::Blocks itself as an IDE, not for help in writing correct code. Please refer to a programmer's handbook or other source of general information about C programming.
Title: Re: Begginer needs help with some (probably basic) errors
Post by: Jenna on May 01, 2009, 07:29:12 pm
Sorry, but the Code::Blocks forums are only for issues related to Code::Blocks itself as an IDE, not for help in writing correct code. Please refer to a programmer's handbook or other source of general information about C programming.

Therefore the topic gets locked !