Sunday, November 3, 2013

Module VII & VIII

Description of Module 7 and 8 

http://youtu.be/Ui1dpL6u0Gc (Module VII & VIII video tutorial)


This application program  have consist with variable, operator, control  flow, function, array and link list that write in c programming in visual studio 2012.
I would like to brief describe with the process of code that consist with variable, operator,  control  flow, function, array and link list relate with how to call the variable name to copy string , define array in data type of variable, use pointer function with link list, putting condition to pointer and link list condition.
Please look the flowchart that describes about the process of the application program in below:
Description the process of code that have command for detail of code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define RECORDS 6 // declaration global variable
main( )
struct animal {
       char name[25]; /* declaration data type of variable of the animals name */
       char breed[25]; /* The type of animal */
       struct animal *next; /* a pointer to another record of this type */
}
*point, *start, *prior; /* this defines 3 pointers, no variables */
int index;  /* the first record is always a special case */
start = (struct animal *)malloc(sizeof(struct animal));
strcpy(start ->name,"general"); // copying string
strcpy(start ->breed,"Mixed Breed");
start->next = NULL;
prior = start;/* a loop can be used to fill in the rest once it is started */
for (index = 0;index < RECORDS;index++) {
              point = (struct animal *)malloc(sizeof(struct animal));
              strcpy(point->name,"Frank");
              strcpy(point->breed,"Laborador Retriever"); //point->age = 3;
              point->next = point;/* point last "next" to this record */
              point->next = NULL; /* point this "next" to NULL */
              prior = point; /* this is now the prior record */
}/* now print out the data described above */
point = start;
do {
prior = point->next;
printf("%s is a %s,and is %s\n", point->name, point->breed, point->breed);
point = point->next;
} while (prior != NULL);/* good programming practice dictates that we free up the */
/* dynamically allocated space before we quit */
point = start; /* first block of group */
do {
              prior = point->next; /* next block of data */
              free(point); /* free present block */
              point = prior; /* point to next */
              } while (prior != NULL); /* quit when next is NULL */
       system ("pause");
       return 0;
}
Please look the output result of code in below:


No comments:

Post a Comment