 Link list in keil uvision simulator
sangram mali
Hello friends, I am trying to write down link list program given
below but, it is not working. Instead of using struct pointer I am
able to access structure member. But, why struct pointer is not
working. If anybody can answer this question then please do reply.
Thanks in advance Sangi
#include<stdio.h>
#include<stdlib.h>
#include<LPC21xx.h>
struct emp
{ char name[50]; char post[20]; struct emp* next;
}*e1;
// struct emp ; int ch1,i;
void main()
{
// ch1ar *ch11; /* initialize the serial interface */ PINSEL0 =
0x00000055 ; /* Enable RxD0 and TxD0 */ U0LCR = 0x83; /* 8 bits, no
Parity, 1 Stop bit */ U0DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock
*/ U0LCR = 0x03; /* DLAB =0 */ while(1){ e1 = malloc(sizeof(struct
emp)); printf("\n\nEnter employee data\n"); i=0; printf("Enter
employee name\n");
ch1 = putchar(getchar()); while(ch1 != 0x0d && i < 0) {
(*e1).name[i] = ch1; ch1 = getchar(); putchar(ch1); i++; }
(*e1).name[i] = 0x0d; i=0; printf("\nEnter employee post\n"); ch1 =
putchar(getchar()); while(ch1 != 0x0d && i < 20) {
(*e1).post[i] = ch1; ch1 = putchar(getchar()); i++; } (*e1).post[i] =
0x0d; printf("\n\nEmployee information\n"); i=0; printf("Employee
name : "); while((*e1).name[i] != 0x0d ) { putchar((*e1).name[i]);
i++; }
i=0; printf("\nEmployee post : "); while((*e1).post[i] != 0x0d ) {
putchar((*e1).post[i]); i++; } }
}
|