Author Topic: Begginer needs help with some (probably basic) errors  (Read 4222 times)

dschiller

  • Guest
Begginer needs help with some (probably basic) errors
« 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".
« Last Edit: May 01, 2009, 05:18:21 pm by dschiller »

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Begginer needs help with some (probably basic) errors
« Reply #1 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.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7256
Re: Begginer needs help with some (probably basic) errors
« Reply #2 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 !