#include<stdio.h> #include<stdlib.h> struct node{ int data; struct node* ptr; }; void push(struct node**,int); void build(struct node**); int getn(struct node*, int); int main(){ int n; struct node first; struct node* head; *head = first; first.data = 1; first.ptr = NULL; build(&head); n=getn(head,1); return 0; } void build(struct node** send){ push(send,344); push(send,65); push(send,44); } void push (struct node** a, int datum){ struct node* temp; temp = malloc(sizeof(struct node)); temp->data = datum; temp->ptr = *a; *a = temp; } int getn(struct node* top, int index){ int n,k; struct node* current = top; for(n=0; n<index;n=n+1){ k = current->data; current = current->ptr; } return k; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)