Pb de convertion avec un vieux borland c++

myogtha Messages postés 4 Date d'inscription jeudi 17 octobre 2002 Statut Membre Dernière intervention 3 avril 2003 - 2 avril 2003 à 19:55
CoreBreaker Messages postés 540 Date d'inscription dimanche 23 mars 2003 Statut Membre Dernière intervention 5 octobre 2007 - 3 avril 2003 à 23:05
j'ai un probléme en cour j'utilise une version plus ancienne que ma 5.01 et lorsque je compile mon prog il me dis :
graphic.h(50,22):convertion may lose significant digit
graphic.h(71,15):call to indentify function delay
...
puis,
serpent.cpp(18,17)....solid_fill,detect,grOk...

je dois faire quoi merci de me filer un coup de main
bye jmb

3 réponses

CoreBreaker Messages postés 540 Date d'inscription dimanche 23 mars 2003 Statut Membre Dernière intervention 5 octobre 2007 1
2 avril 2003 à 20:35
> graphic.h(50,22):convertion may lose significant digit
losque tu fais:
long l;
short s=l;
ce message est produit c'est un avertissement pour t'indique que pour passer d'un long (32bits) en un short (16bits) tu vas perdre les 16bits de poids faible. Si l = 0x12345678 alors
s = 0x5678, tu perds 0x1234. La preuve c'est que si tu fais ensuite:
long l2= s;
l2 contiendra 0x5678.
Pour éviter ce message il faut imposer au compilateur que l soit vient un short par un casting:
short s= (short)l;

Tu peux aussi désactiver ce message par un pragma.

Pour les autres messages il faut que je vois ton source.

Core Breaker :)
0
myogtha Messages postés 4 Date d'inscription jeudi 17 octobre 2002 Statut Membre Dernière intervention 3 avril 2003
3 avril 2003 à 10:17
je tiens juste à vous dire que je debute, et que ce prog tourne pas mais qu'il se compile completement avec un vieux borland

voici mon prog ne rigolé pas et ne me dite pas d'utilisé les pointeur je sais pas encore faire je n'ai fais que de l'algorithmie, désolé....:-)

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include

typedef struct{
int x;
int y;
}point;

point p2[50];
void afficheballedeb()
{
p2[0].x =320;
p2[0].y =240;
setfillstyle(SOLID_FILL, RED);
bar(p2[0].x,p2[0].y,p2[0].x+4,p2[0].y+4);
p2[1].x =324;
p2[1].y =240;
setfillstyle(SOLID_FILL, RED);
bar(p2[1].x,p2[1].y,p2[1].x+4,p2[1].y+4);
p2[2].x =328;
p2[2].y =240;
setfillstyle(SOLID_FILL, RED);
bar(p2[2].x,p2[2].y,p2[2].x+4,p2[2].y+4);
}

void changeTable(int indmax,int indtete,int dx, int dy)
{
if ( indtete<indmax )
{
p2[indtete].x=p2[indtete].x+dx;
p2[indtete].y=p2[indtete].y+dy;
}
else
{
indtete=0;
}
}

void afficheballered(int indtete)
{
setfillstyle(SOLID_FILL, RED);
bar(p2[indtete].x,p2[indtete].y,p2[indtete].x+3,p2indtete].y+3);
}
void afficheterrain()
{
rectangle(0,0,639,479);
}
void graphicdriver()
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
}

//-------------------------------------------------------------------//
//
// D.E.B.U.T SERPENT
//
//
//-------------------------------------------------------------------

int main(void)
{
int i,x,y,dx,dy,indtete,indmax;
char car;
graphicdriver();
afficheballedeb();
indtete=0;
indmax=2;
while ( car!=27 )
{
if (kbhit())
{
car = getch();
if (car==72)
{
dx = -1;
dy = 0;
}
if (car==80)
{
dx = 0;
dy = -1;
}
if (car==75)
{
dx = 0;
dy = 1;
}
if (car==77)
{
dx = 1;
dy = 0;
}
changeTable(indmax,indtete,dx,dy);
}
indtete=indtete+1;
afficheballered(indtete);
afficheterrain();
delay(40);
}
/* clean up */
closegraph();
return 0;
}
0
CoreBreaker Messages postés 540 Date d'inscription dimanche 23 mars 2003 Statut Membre Dernière intervention 5 octobre 2007 1
3 avril 2003 à 23:05
Voilà:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>

#define LONGUEUR 50

typedef struct
{
int x;
int y;
int affiche;
} point;

point p2[LONGUEUR];

void afficheballedeb(void)
{
p2[0].x= 320;
p2[0].y= 240;
setfillstyle(SOLID_FILL, RED);
bar(p2[0].x, p2[0].y, p2[0].x+4, p2[0].y+4);
p2[1].x= 324;
p2[1].y= 240;
setfillstyle(SOLID_FILL, RED);
bar(p2[1].x, p2[1].y, p2[1].x+4, p2[1].y+4);
p2[2].x= 328;
p2[2].y= 240;
setfillstyle(SOLID_FILL, RED);
bar(p2[2].x, p2[2].y, p2[2].x+4, p2[2].y+4);
}

void changeTable(int indmax, int *indtete, int dx, int dy)
{
if( *indtete < indmax )
{
p2[*indtete].x+= dx;
p2[*indtete].y+= dy;
}
else
*indtete= 0;
}

void afficheballered(int indtete)
{
setfillstyle(SOLID_FILL, RED);
bar(p2[indtete].x, p2[indtete].y, p2[indtete].x+3, p2[indtete].y+3);
}

void afficheterrain(void)
{
rectangle(0, 0, 639, 479);
}

void graphicdriver(void)
{
int gdriver= DETECT, gmode, errorcode;

initgraph(&gdriver, &gmode, "");
errorcode= graphresult();
if( errorcode != grOk )
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
}

//-------------------------------------------------------------------//
//
// D.E.B.U.T SERPENT
//
//
//-------------------------------------------------------------------

int main(void)
{
int dx= 0, dy= 0, indtete= 0, indmax= 2;
int fin= 1;

graphicdriver();
afficheballedeb();

while ( fin )
{
changeTable(indmax, &indtete, dx, dy);
indtete= (indtete + 1) % LONGUEUR;
afficheballered(indtete);
afficheterrain();
delay(40);

switch(getch())
{
case 0:
continue;

case 72: // Haut
dx= 0;
dy= -1;
break;

case 80: // Bas
dx= 0;
dy= 1;
break;

case 75: // Gauche
dx= -1;
dy= 0;
break;

case 77: // Droite
dx= 1;
dy= 0;
break;

case 27: // Echap
fin= 0;
}
}

/* clean up */
closegraph();
return 0;
}

Core Breaker :)
0
Rejoignez-nous