int format double arg calculations

Go4Expert Member
28Mar2006,20:48   #1
musicmancanora4's Avatar
Hey guys imtrying to calculate a figure but i get an error int format double arg
i want to calculate the sizetotal but also round off the sizetotal. How can i do that?




Code:
#define MINE_DENSITY 0.6

void placeMines(char minefield[MAX_GRID][MAX_GRID], unsigned size)
{

  float sizetotal;
 
  
  sizetotal = size * MINE_DENSITY;
  
   
  printf("%d", sizetotal);

}
Team Leader
28Mar2006,23:36   #2
coderzone's Avatar
It shouldnt be an error I guess. It should be warning.

Try writing
sizetotal = (float)(float)size * MINE_DENSITY;

and

printf("%f", sizetotal);