विजुअल स्टूडियो 2008 सीलिंक्ड सूची पूंछ को जोड़ने, भ्रम
क्या मैं इस लिंक्ड सूची के बारे में समझ में नहीं आता है, तो बयान के बाकी हिस्से में पूंछ को जोड़ने है।
जब सिर और पूंछ को नोड_टैम्प के स्मृति पते को दोनों पूंछ और सिर दोनों को उसी स्मृति स्थान पर इंगित किया जाता है।
हालांकि, अन्य भाग में वास्तव में सिर अभी भी पूंछ को इंगित कर रहा है। ऐसा कुछ है जिसे मैं समझा नहीं सकता और दूसरे भाग के बारे में नहीं समझता?
मुझे उम्मीद है कि कोई मेरे लिए बेहतर समझा सकता है।
static struct convert_temp
{
size_t cel;
size_t fah;
struct convert_temp *next;
} *head = NULL, *tail = NULL;
/** Add the new converted temperatures on the list */
void add(size_t cel, size_t fah)
{
struct convert_temp *node_temp = NULL; /* contain temp data */
node_temp = malloc(sizeof(*node_temp));
if(node_temp == NULL)
{
fprintf(stderr, "Cannot allocate memory [ %s ] : [ %d ]\n",
__FUNCTION__, __LINE__);
exit(0);
}
/* Assign data */
node_temp->cel = cel;
node_temp->fah = fah;
node_temp->next = NULL;
if(head == NULL)
{
/* The list is at the beginning */
head = node_temp; /* Head is the first node = same node */
tail = node_temp; /* Tail is also the last node = same node */
}
else
{
/* Append to the tail */
tail->next = node_temp;
/* Point the tail at the end */
tail = node_temp;
}
}
डीबगर के साथ इसके माध्यम से जाएं। –