HomeTOOLSEXAMPLESEXPLORE EMBEDDEDE CSERVICESECU SAMPLESRegistration
Embedded C programming Tutorial , Keil C ide , microsoftware.gr
Keil CRC and CAN BUS codes.
1. Shift led left
2.It's time for DAVE! <7/6/13>
3.Capture/Compare unit 6
4.ASC0-GPT1-MACROS
5.ASC0-FIFO-PEC
6.Analog converter
7.Memory manipulation routines
8. Recursion
9.Understanding interrupt priorities using CAPCOM2 module
10. POINTERS TO FUNCTION <4/7/13>,<4/28/13>
11.Memory models, memory types
12. The heap , part 1
13. The heap , part 2
14. The heap , part 3
15. Structure example
16. Nested structures, Array of structures.
17. Passing array of structures to function using pointers.<1/5/13>
18. Self Referential Structures
19. BITFIELDS
20. Linked list example
21. Circular linked list
22. Union example
23. Enumeration example
24. Watchdog timer example
25. Void pointer example <7/4/13>
26. The sieve of Eratosthenes
27. The stack
28. Union and bitfields as flags example. <6/23/13>
29. Look up table example. <8/11/13>
30. Seven segment display multiplexing -four digits with dot- example
31. LCD character display example - JHD162A
32. Hash table introduction example <8/27/14>
33. Array of Linked Lists example
34. Array of Linked lists-more functions included.
35. Hash table construction,searching and printing.
36. Fininte state machines- a first approach.
37. Finite state machines- two events example.
38. SPI port and an AT25128 serial eeprom hardware.
39. CRC CHECK
40. Definite Integral Calculator for Scientists, Engineers...
41 .Hamming distance of a CRC polynomial
42. Linux play starting.
43. Galois GF(2^4) Finite Field
44. Construct your own time triggered real time operating system.
45. CANBUS C CODE EXAMPLE.
34. Array of Linked lists-more functions included.

 

34. Array of Linked Lists-more functions included-example.



As you know pointers is a powerful tool of C language. You can manipulate data stored in RAM memory via functions not having the need to copy the data to the functions. Simply you have to insert at the functions pointers pointing to the data and you can now manipulate the data as they are staying at their memory place.
The philosophy of pointers is also applied and about Linked List. To manipulate the data stored at the nodes of a Linked List via a function we have simply to insert to the function a pointer pointing to the Linked List
Since the head node of a list is a pointer to a structure genarated by malloc() function, to be able to refer to the list via pointer we need an other pointer pointing to the pointer of the head node: a pointer to a pointer that points to a structure node.

struct node **head

At the example we make an array of six lists   struct node far **  a[6];
All pointers of all nodes of all lists are saved to a two dimensions array
struct  node  far *x[6][10]; so we are able to refer to each one node.

For example,
indexes  of nodes:
                 0        1        2     3      4    ...
the a[2] is   "a"->  "b"->  "c"

the a[3] is   "a"-> "b"-> "c"-> "d"-> "e"

the a[4] is   "e"-> "b"-> "c"-> "d" 

New functions are included:
1. struct node far* AppendNode(struct node far** headRef, char* num ); 
   adds nodes to a list.
example :AppendNode(a[3],c0)  ;

we add strings like:
char* c0="a";
char* c1="b";
char* c2="c";
char* c3="d";
char* c4="e";
char* c5="f";

2. int Length(struct node far* head);
finds the length of a list.

3. void printnode( struct node *ptr );
prints a node.

4. void printlist( struct node ** head ); 
prints a list.
example: printlist (a[2]);

5. void insert_at_middle( struct node far **head, char* name, int i );
inserts a new node ,name, before node with index i, and re-connect the "brokrn chain" of the list.
example:  insert_at_middle (a[2], "abc",2 );

6. void  search_in_list(char* num, struct node **prev);
search the list for the string num.
example: search_in_list("b", a[4]);

7. struct node * initnode( char *name );
initiates a new node using malloc().
example: initnode ("abc");

8. void deletenode( struct node far **head, int i );
Deletes a specified node and reconnect the broken chain.
example:  deletenode (a[2],2);

9. void delete_all_after_node( struct node far **head,int i );
deletes all the nodes after the ith node.
example: delete_all_after_node (a[2],1);

10. void deletelist( struct node far **head );
deletes all the list.
example: deletelist(a[3]);

11. unsigned  int linked_list_index (struct node  far **z );
returns the index of the list.
example: unsigned int linked_list_index (a[2]); returns 2

Remember that places for lists are found by malloc() and &(a[2])+1!= &a[3]. 


The C code.                                     Result at Hyperterminal.


 

Home|TOOLS|EXAMPLES|EXPLORE EMBEDDEDE C|SERVICES|ECU SAMPLES|Registration