Les programmeurs c++ ,pourquoi pas de reponse :/
wikilili
Messages postés
197
Date d'inscription
Statut
Membre
Dernière intervention
-
wikilili Messages postés 197 Date d'inscription Statut Membre Dernière intervention -
wikilili Messages postés 197 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
s'il vous plait j'arrive pas a trouver l'erreur dans ce code mon IDE me signal la section que je vais poser en commentaire comme erreur de conversion impossible ou quelque chose comme ca . mercii d'avance vola le code
POINT MousePos( void )
{
POINT Pos;
RECT rect;
GetCursorPos( &Pos );
GetWindowRect( Hwnd, &rect );
Pos.x = Pos.x - rect.left - 20;
Pos.y = Pos.y - rect.top - 82;
return Pos;
}
void SetWindowTextToInteger( HWND Hwnd, char* TextToNum )
{
int i = 0, j = 0, TextToNumLen = strlen( TextToNum );
char* NewWindowText = NULL;
NewWindowText = (char*) malloc( sizeof( char ) * ( TextToNumLen + 1 ) );
for( i = 0; i < TextToNumLen + 1; i++ )
NewWindowText[ i ] = '\0';
for( i = 0; i < TextToNumLen; i++ )
{
if( TextToNum[ i ] > 47 && TextToNum[ i ] < 58 )
{
NewWindowText[ j ] = TextToNum[ i ];
j++;
}
}
if( NewWindowText[ 0 ] == '0' && strlen( NewWindowText ) > 1 )
{
for( i = 0; i < TextToNumLen; i++ )
{
if( NewWindowText[ i ] != '0' || i > (int) strlen( NewWindowText ) - 2 )
break;
}
for( j = 0; j < TextToNumLen - i; j++ )
TextToNum[ j ] = NewWindowText[ i + j ];
TextToNum[ j ] = '\0';
strcpy( NewWindowText, TextToNum );
}
SetWindowText( Hwnd, NewWindowText );
free( NewWindowText );
NewWindowText = NULL;
}
void SetWindowTextToReal( HWND Hwnd, char* TextToFloat, int MaxTextLen )
{
int i = 0, j = 0, TextToFloatLen = strlen( TextToFloat );
char* NewWindowText = NULL;
NewWindowText = (char*) malloc( sizeof( char ) * ( MaxTextLen + 1 ) );
for( i = 0; i < MaxTextLen + 1; i++ )
NewWindowText[ i ] = '\0';
for( i = 0; i < TextToFloatLen; i++ )
{
if( TextToFloat[ i ] == 46 || ( TextToFloat[ i ] > 47 && TextToFloat[ i ] < 58 ) )
{
NewWindowText[ j ] = TextToFloat[ i ];
j++;
}
}
if( NewWindowText[ 0 ] == '.' )
{
for( i = MaxTextLen - 1; i > 0; i-- )
NewWindowText[ i ] = NewWindowText[ i - 1 ];
NewWindowText[ 0 ] = '0';
}
SetWindowText( Hwnd, NewWindowText );
free( NewWindowText );
NewWindowText = NULL;
}
void ReInitializeProgram( void )
{
NewPen( 0, 1, RGB( 255, 0, 0 ) );
NewPen( 1, 1, RGB( 0, 255, 0 ) );
NewBitmap( Hwnd, 1, 5, 7 );
NewBitmap( Hwnd, 2, 5, 7 );
DrawBitmap( HwndImgInit, 1 );
DrawBitmap( HwndImgReco, 2 );
SendMessage( HwndCom, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0 );
MaxIterations = 1000;
ErrorPercentage = 0.5;
Cor = 0.1;
LastTrainingTime = 0;
TotalIterations = 0;
TotalTrainingTime = 0;
NbCar = 0;
---------------------------------------------------------------------------------------
ListView_SetItemText( HwndTraining, 0, 1, "0");
ListView_SetItemText( HwndTraining, 1, 1, "0");
ListView_SetItemText( HwndTraining, 2, 1, "0.0");
ListView_SetItemText( HwndTraining, 3, 1, "0.0");
ListView_SetItemText( HwndTraining, 4, 1, "0"); dans ce bloc tous ces list sont erronés
ListView_SetItemText( HwndTraining, 5, 1, "0");
ListView_SetItemText( HwndTraining, 6, 1, "0.0");
----------------------------------------------------------------------------------------------
SetWindowText( GetDlgItem( Hwnd, EditSymbolToCreate ), "" );
SetWindowText( GetDlgItem( Hwnd, EditMaxIterations ), "1000" );
SetWindowText( GetDlgItem( Hwnd, EditCorrectionValue ), "0.1" );
SetWindowText( GetDlgItem( Hwnd, EditErrorPercentage ), "0.5" );
free( EntriesState );
free( Weights );
free( Sums );
free( Output );
free( NeuronName );
EntriesState = (int*) malloc( sizeof( int ) * EntryNumber );
Weights = (double*) malloc( sizeof( double ) * EntryNumber );
Sums = (double*) malloc( sizeof( double ) );
Output = (double*) malloc( sizeof( double ) );
NeuronName = (char*) malloc( sizeof( char ) * 16 );
}
s'il vous plait j'arrive pas a trouver l'erreur dans ce code mon IDE me signal la section que je vais poser en commentaire comme erreur de conversion impossible ou quelque chose comme ca . mercii d'avance vola le code
POINT MousePos( void )
{
POINT Pos;
RECT rect;
GetCursorPos( &Pos );
GetWindowRect( Hwnd, &rect );
Pos.x = Pos.x - rect.left - 20;
Pos.y = Pos.y - rect.top - 82;
return Pos;
}
void SetWindowTextToInteger( HWND Hwnd, char* TextToNum )
{
int i = 0, j = 0, TextToNumLen = strlen( TextToNum );
char* NewWindowText = NULL;
NewWindowText = (char*) malloc( sizeof( char ) * ( TextToNumLen + 1 ) );
for( i = 0; i < TextToNumLen + 1; i++ )
NewWindowText[ i ] = '\0';
for( i = 0; i < TextToNumLen; i++ )
{
if( TextToNum[ i ] > 47 && TextToNum[ i ] < 58 )
{
NewWindowText[ j ] = TextToNum[ i ];
j++;
}
}
if( NewWindowText[ 0 ] == '0' && strlen( NewWindowText ) > 1 )
{
for( i = 0; i < TextToNumLen; i++ )
{
if( NewWindowText[ i ] != '0' || i > (int) strlen( NewWindowText ) - 2 )
break;
}
for( j = 0; j < TextToNumLen - i; j++ )
TextToNum[ j ] = NewWindowText[ i + j ];
TextToNum[ j ] = '\0';
strcpy( NewWindowText, TextToNum );
}
SetWindowText( Hwnd, NewWindowText );
free( NewWindowText );
NewWindowText = NULL;
}
void SetWindowTextToReal( HWND Hwnd, char* TextToFloat, int MaxTextLen )
{
int i = 0, j = 0, TextToFloatLen = strlen( TextToFloat );
char* NewWindowText = NULL;
NewWindowText = (char*) malloc( sizeof( char ) * ( MaxTextLen + 1 ) );
for( i = 0; i < MaxTextLen + 1; i++ )
NewWindowText[ i ] = '\0';
for( i = 0; i < TextToFloatLen; i++ )
{
if( TextToFloat[ i ] == 46 || ( TextToFloat[ i ] > 47 && TextToFloat[ i ] < 58 ) )
{
NewWindowText[ j ] = TextToFloat[ i ];
j++;
}
}
if( NewWindowText[ 0 ] == '.' )
{
for( i = MaxTextLen - 1; i > 0; i-- )
NewWindowText[ i ] = NewWindowText[ i - 1 ];
NewWindowText[ 0 ] = '0';
}
SetWindowText( Hwnd, NewWindowText );
free( NewWindowText );
NewWindowText = NULL;
}
void ReInitializeProgram( void )
{
NewPen( 0, 1, RGB( 255, 0, 0 ) );
NewPen( 1, 1, RGB( 0, 255, 0 ) );
NewBitmap( Hwnd, 1, 5, 7 );
NewBitmap( Hwnd, 2, 5, 7 );
DrawBitmap( HwndImgInit, 1 );
DrawBitmap( HwndImgReco, 2 );
SendMessage( HwndCom, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0 );
MaxIterations = 1000;
ErrorPercentage = 0.5;
Cor = 0.1;
LastTrainingTime = 0;
TotalIterations = 0;
TotalTrainingTime = 0;
NbCar = 0;
---------------------------------------------------------------------------------------
ListView_SetItemText( HwndTraining, 0, 1, "0");
ListView_SetItemText( HwndTraining, 1, 1, "0");
ListView_SetItemText( HwndTraining, 2, 1, "0.0");
ListView_SetItemText( HwndTraining, 3, 1, "0.0");
ListView_SetItemText( HwndTraining, 4, 1, "0"); dans ce bloc tous ces list sont erronés
ListView_SetItemText( HwndTraining, 5, 1, "0");
ListView_SetItemText( HwndTraining, 6, 1, "0.0");
----------------------------------------------------------------------------------------------
SetWindowText( GetDlgItem( Hwnd, EditSymbolToCreate ), "" );
SetWindowText( GetDlgItem( Hwnd, EditMaxIterations ), "1000" );
SetWindowText( GetDlgItem( Hwnd, EditCorrectionValue ), "0.1" );
SetWindowText( GetDlgItem( Hwnd, EditErrorPercentage ), "0.5" );
free( EntriesState );
free( Weights );
free( Sums );
free( Output );
free( NeuronName );
EntriesState = (int*) malloc( sizeof( int ) * EntryNumber );
Weights = (double*) malloc( sizeof( double ) * EntryNumber );
Sums = (double*) malloc( sizeof( double ) );
Output = (double*) malloc( sizeof( double ) );
NeuronName = (char*) malloc( sizeof( char ) * 16 );
}
A voir également:
- Les programmeurs c++ ,pourquoi pas de reponse :/
- Réponse automatique thunderbird - Guide
- Réponse automatique gmail - Guide
- Code ascii : 37 2d 3f 3d 31 réponse ✓ - Forum Loisirs / Divertissements
- Que cachent les manchots sur la plage pix reponse - Forum Graphisme
- Annuaire inversé portable gratuit réponse immédiate ✓ - Forum Vos droits sur internet
2 réponses
Salut wikilili,
Ce message n'est pas une erreur de compilation, mais un avertissement.
Selon https://docs.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-listview_setitemtext?redirectedfrom=MSDN
ListView_SetItemText est une macro dont le 4ème argument est de type :
Si tu veux éliminer l'avertissement, tu dois pouvoir faire ceci (non testé) :
Dal
Ce message n'est pas une erreur de compilation, mais un avertissement.
Selon https://docs.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-listview_setitemtext?redirectedfrom=MSDN
ListView_SetItemText est une macro dont le 4ème argument est de type :
LPCTSTR pszTextor, en faisant :
ListView_SetItemText(HwndTraining, 0, 1, "0");tu passes en fait une constante, d'où l'avertissement.
Si tu veux éliminer l'avertissement, tu dois pouvoir faire ceci (non testé) :
ListView_SetItemText(HwndTraining, 0, 1, const_cast<LPCTSTR>"0");Cela dit, comme la macro attend un LPCTSTR, tu pourrais plutôt définir des variables pour faire les choses comme le demande le code.
LPCTSTR du_texte = "0"; ListView_SetItemText(HwndTraining, 0, 1, du_texte);
Dal
wikilili
Messages postés
197
Date d'inscription
Statut
Membre
Dernière intervention
2
merciiiii Dal
Peut-être parce que tu ne reportes pas l'erreur de compilation, ni n'indique à quelle ligne ça correspond dans ton code ? Mets-toi à notre place, tu ne nous donne qu'un extrait du code, on a donc aucune chance de pouvoir le compiler...
voila le warning que j'obtien ,et meme que donne plus de detail je n'obtiens pas d'aide comme au paravant et j'ai craint que le service fourni est en shut ,bon oubliant ca voila le warning : deprecated conversion from string constant to 'LPSTR {aka char*}' j'utilse IDE eclipse indegio (mingw) merciii