Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8271971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:59:06+00:00 2026-06-08T06:59:06+00:00

#include <stdio.h> typedef int element_type; typedef struct Cell{ element_type e; struct Cell *next; }

  • 0
#include <stdio.h>
typedef int element_type;

typedef struct Cell{
  element_type e;
  struct Cell *next; 
} Cell,*List;

Cell *End(List L){
  Cell *q = L;
  while (q->next != NULL){
    q = q->next;
  }
  return q;
}

void Insert(Cell *p, element_type x){
  //Create new Cell
  Cell *temp = (Cell*) malloc(sizeof(Cell));
  if (temp == NULL){
    printf("Memory Allocation Failed");    
  }
  else{
    temp->e = x;
    temp->next = p->next;
    p->next = temp;
  }
}

element_type Retrieve(Cell *p){
  return p->e;
}
int main(){
  //Initialize the List;
  List L = malloc(sizeof(Cell));
  L->e = NULL;
  L->next = NULL;

  element_type x = 10;
  Insert(L,x);
  printf("Just retrievd the item %d\n",Retrieve(L));
  return 1;
}

List_pointer.c: In function ‘Insert’:
List_pointer.c:19:24: warning: incompatible implicit declaration of built-in function ‘malloc’ [enabled by default]
List_pointer.c: In function ‘main’:
List_pointer.c:35:12: warning: incompatible implicit declaration of built-in function ‘malloc’ [enabled by default]
List_pointer.c:36:8: warning: assignment makes integer from pointer without a cast [enabled by default]

Thanks for all your helps, and I for the part with struct now. However, when I tried to use malloc, I got the warnings again on incompatible declaration. I thought malloc returns a generic pointer to NULL, and hence there shouldn’t be any issue with casting? I just not sure what I did wrong here.

Also for those of you who wonders why I would implement such a weird interface, I was following the interfaces provided by the book “Data Structure and Algorithm” by Aho. The sample codes were given in Pascal, pretty old style. Although I think there are some merits to learn this super old style way of designing data structure.

Update:

I just forgot to include the stdlib.h header for malloc!
Please refer to this link incompatible implicit declaration of built-in function ‘malloc’

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:59:10+00:00Added an answer on June 8, 2026 at 6:59 am

    You’ll need to change

    typedef struct {
    

    to

    typedef struct Cell {
    

    The typedef struct { /* ... */ } Cell; defines a tagless struct. In effect, the struct itself has no name via which it can be referred to directly. The name Cell is simply the name of a typedef that refers to this unnamed struct.

    When you use struct Cell to declare next, it means “the struct named Cell.” But, there isn’t a struct named Cell, because the struct you defined has no name.

    By naming the struct (giving it a tag), you can refer to it using the struct Cell notation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *next; }; void insert( struct
#include <stdio.h> #include <stdlib.h> typedef int element; struct cell { element e; struct cell
#include <stdio.h> void wrapperPrint(char* s) { printf(s); return; } int main() { wrapperPrint(Hello world\n);
#include <stdio.h> #include <stdlib.h> typedef struct { char *Name; int grade; int cost; }Hotel;
#include<stdio.h> #define A(int x) printf(%d\n,x) #define AS(A) A(20) typedef struct{ int *m; int n;
#include <stdio.h> #include <stdlib.h> #include <string.h> void main() { typedef int (FuncPtr)(); char asmFunc[]
This produces an incompatibility warning: #include <stdlib.h> #include <stdio.h> typedef struct { int key;
Here's my code. #include<stdio.h> struct element { int value; char activity; }; typedef struct
#include<stdio.h> #include<stdlib.h> char* re() { char *p = hello; return p; } int main()
#include <stdio.h> #include <stdlib.h> int main(void) { int x; int *in, *begin; in =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.