Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

return pointer of structure

Status
Not open for further replies.

jab99407

Member
I do not understand working of function in the given code. This is a sample function that will be in the linked list. I know only function take data and return pointer

Is it a useful function that adds a new node in the list?

Code:
#include<stdio.h>
#include<stdlib.h>

struct Node{
  int data;
  struct Node *next;
};

struct Node * New_Node( int data){
 
  struct Node *p = malloc(sizeof(*p));
  p->data = data;
  p->next = NULL;
  return p;
}

int main ()
{
    struct Node * pS1;
    struct Node * pS2;

    pS1 = newNode(100);
    pS2 = newNode(456);
    return 0;
}
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top