C program for linked list

1 answer

Answer

1252688

2026-05-20 13:25

+ Follow

#include<stdio.h>

#include<string.h>

#include<stdlib.h>

struct node

{

int n;

struct node *ptr;

};

int main(void)

{

struct node *n1,*strt,*temp;

char a;

int cnt=0,i=0;

//char a[50],temp[100],line[100],Word[50],e[50],final[100];

//FILE *fp,*fp1,*fp2;

strt=malloc(sizeof(struct node));

strt->n=90;

strt->ptr=NULL;

for(a='y';a!='n';)

{

n1=malloc(sizeof(struct node));

n1->n=++cnt;

n1->ptr=strt;

strt=n1;

scanf("%c",&a);

}

// ptr[1]=40;

// ptr[2]=30;

n1=strt;

while(n1!=NULL)

{ printf("\n %d at loc %p",n1->n,n1);

printf(" locaa %p \n",n1->ptr);

n1=n1->ptr;

}

return 0;

}

~

~

~

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.