Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

724
Vistas
Struct keyword in function parameters, what is the difference?

I wonder, what is the difference between:

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

and

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

Why do we need struct keyword in second example?

Also, what is the difference between

void Foo(Node* head) 
{
    Node* cur = head;
    //....
}

and

void Foo(struct Node* head) 
{
    struct Node* cur = head;
    //....
}
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Only the declarations including struct are valid in C. There is no difference in C++.

However, you can typedef the struct in C, so you don’t have to write it every time.

typedef struct Node
{
  int data;
  struct Node *next;  // we have not finished the typedef yet
} SNode;

SNode* cur = head;    // OK to refer the typedef here

This syntax is also valid in C++ for compatibility.

over 4 years ago · Santiago Trujillo Denunciar

0

Struct node is a new user defined datatype that we create. And unlike classes the new data type using structures is "struct strct_name" , ie; u need the keyword struct in front of the struct_name. For classes u do not need keywords in front of the new data type name. eg;

class abc
{
  abc *next;
};

and when u declare variables

abc x;

instead of struct

abc x;

in case of structures . Also understand that by the statement

struct node * next;

we are trying to create a pointer that points to a variable of type "strcut node", which is called a self referential pointer in this case since it points to the parent structure.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda