Revision as of 11:30, 27 February 2012 by Song110 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Lecture 13_ notes_ Kailu Song 1. Announcement:

   The link to the class slides:https://docs.google.com/present/embed?id=dcch9sqd_404d4pbkbgv&size=l

2.debug details:

   >make test (instead the test line)
   diff output1 solution1 (tell you the different between the two files)
   be aware of segment fault (problem from the memeory)
                      infinite loop
                      recursion

3. binary file:

   open: fopen(filename,"wb");(write binary file)
                                     "rb" (read binary file)
   write: fwrite(address of the object, size,number,file pointer);
             fwrite(&v, sizeof(vector), 5(number of elements of an array), pointer);

4.what if there is an object with an pointer? type of struct

   {
      char* name;
      int year;
      int month;
      int date;
   } Person;

Person Person_construct(char *n,int y, int m, int d)

   {
       Person p;
       P.name = malloc(sizeof(char)*strlen(n)+1);
       streoy(p.name.n);
       p.year = y;
    }return p;

void Person_destruct(person p) {

  free(p.name); 

} Person p = person.construct("Alice", 1981,11,22); Person_destruct(p);

Alumni Liaison

Ph.D. on Applied Mathematics in Aug 2007. Involved on applications of image super-resolution to electron microscopy

Francisco Blanco-Silva