Weiß jemand, warum das Mitglied Node_ptr next;
macht die Elemente des Arrays poly[1]
und poly[2]
den falschen Wert anzeigen? Wenn ich Node_ptr next;
von der Struktur (struct node
) zu entfernen, ich bin in der Lage den richtigen Wert für den Indizes 1 und 2Struktur, Array-Anzeige falsche Werte
hier zu bekommen, ist mein Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct node *Node_ptr;
struct node {
int coef;
int exp;
Node_ptr next;
};
int main()
{
struct node p1_terms[] = {10, 1000, 5, 14, 1, 0};
struct node p2_terms[] = {3, 1990, 2, 1492, 11, 5};
struct node poly[20];
poly[0] = p1_terms[0];
poly[1] = p1_terms[1];
poly[2] = p1_terms[2];
printf("Your polynomials are: \n%dx^%d+%dx^%d+%dx^%d", poly[0].coef, poly[0].exp, poly[1].coef, poly[1].exp, poly[2].coef, poly[2].exp);
int siz = sizeof(poly);
printf("\n\nSize of the array: %d bytes \n",siz);
return 0;
}
'{10, 1000, 5, 14, 1, 0};' falsche Initialisierungsliste. -> '{{10, 1000}, {5, 14}, {1, 0}}' – BLUEPIXY