2019.10.22.pdf - Reference of the Day ‣ The International Obfuscated C Code Contest • others find your C code hard to understand • turn a problem

2019.10.22.pdf - Reference of the Day ‣ The International...

This preview shows page 1 - 13 out of 48 pages.

The International Obfuscated C Code Contest others find your C code hard to understand? turn a problem into a "feature"! •see - - International_Obfuscated_C_Code_Contest - - - ever-seen Reference of the Day 1
Image of page 1
Announcements old exams •content of course has varied •no answer key provided reminder about midterm exam •Monday, October 28, 2019 •17:30 - 19:00 (5:30 p.m. - 7:00 p.m.) •location: HLTH E1150 •coverage: through today's lecture •format: all multiple-choice •OpScan sheet 2
Image of page 2
Image of page 3
Clarification 4
Image of page 4
Results of Oct 17 Poll relevant code: possible answers: 5 int a = 3, b = 5; swap3(&a, &b); printf("a = %d, b = %d\n", a, b); void swap3(int *x, int *y) { int *t; t = x; x = y; y = t; } (a) 3 5 (b) 5 3 This code does not modify a or b a=3 b=5
Image of page 5
Results of Oct 17 Poll relevant code: possible answers: 6 int a = 3, b = 5; swap3(&a, &b); printf("a = %d, b = %d\n", a, b); void swap3(int *x, int *y) { int *t; t = x; x = y; y = t; } (a) 3 5 (b) 5 3 lab 3b, must print double backslash characters if you want one in the output
Image of page 6
Picking up from last day … 7
Image of page 7
Looping Through Vectors highlights of example_38.c and example_38_log.txt •standard way to loop through elements of a character vector e.g. basic Strlen() function: 8 int Strlen(char *s) { int n; for (n = 0; *s != '\0'; s++) n++; return n; }
Image of page 8
Looping Through Vectors highlights of example_38.c and example_38_log.txt •standard way to loop through elements of a character vector e.g. basic Strcpy() function: 9 void Strcpy(char *src, char *dst ) // assumes space to copy into already exists // and is sufficiently large { for ( ; *src != '\0'; src++, dst++) *dst = *src; }
Image of page 9
Functions and Pointers highlights of example_39.c and example_39_log.txt •functions can return pointers many of the string functions in libc return char* 10
Image of page 10
Strings highlights of example_40.c and example_40_log.txt cbuf allocated and cbuf[0] set to '\0' gets() is not robust •optional to check return value of stdio functions that output to stdout - e.g. if(fputs("input something: ", stdout) == EOF) exit; •definitely check return value of stdio functions that read input 11
Image of page 11
Vector Allocation static allocation •e.g.
Image of page 12
Image of page 13

You've reached the end of your free preview.

Want to read all 48 pages?

  • Spring '14

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes