warning: assignment from incompatible pointer-Typ [standardmäßig aktiviert]
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
double x,y;
printf("Enter a double: ");
scanf("%lf", &x);
printf("Enter another double:");
scanf("%lf", &y);
int *ptr_one;
int *ptr_two;
ptr_one = &x;
ptr_two = &x;
int *ptr_three;
ptr_three = &y;
printf("The Address of ptr_one: %p \n", ptr_one);
printf("The Address of ptr_two: %p \n", ptr_two);
printf("The Address of ptr_three: %p", ptr_three);
return 0;
}
Das problem ist, jedes mal, wenn ich versuchen, zu senden dieser code diese Meldung:
Zuweisung von inkompatiblen Zeigertyp [standardmäßig aktiviert]
Ich dachte, die math.h
könnte es beheben, aber negativ. Bitte brauche Hilfe es zu beheben
- GCC-compiler gibt ausreichende Informationen über die Warnung.
4.c:14:12: warning: incompatible pointer types assigning to 'int *' from 'double *' [-Wincompatible-pointer-types] ptr_one = &x;
Du musst angemeldet sein, um einen Kommentar abzugeben.
Hier:
ptr_one
,ptr_two
undptr_three
sindint*
s und&x
und&y
sinddouble*
s. Sie versuchen, zuweisen einerint*
mit einemdouble*
. Daher die Warnung.Problem beheben, indem ändern der Typen der Zeiger auf
double*
stattint*
ich.e ändern Sie die folgenden Zeilenzu
Unter änderungen sollten tun
Problem in dieser Zuordnung -
Erklären
ptr_one
ansptr_two
als Doppel-Zeiger (double als Datentyp)-Einer warum würde
math.h
wird Ihnen helfen, in dieser Angelegenheit ?