News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Begginer needs help with some (probably basic) errors

Started by dschiller, May 01, 2009, 05:15:57 PM

Previous topic - Next topic

dschiller

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".

TDragon

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.
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Jenna

Quote from: 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.

Therefore the topic gets locked !