Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.
We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.
Thank you for your understanding.
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++; } }
}
Please follow the instructionsc for posting source code!
http://www.keil.com/forum/tips.asp
And use the 'Preview' button to confirm that it's worked!