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...

• 48

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
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
Midterm Exam make sure to fill out the top of the OpScan sheet … correctly! 3 REGULAR ANSWER SHEET OMR TCT OOO1 Name IiHililil N S I D @[email protected]@@oo @@[email protected]@oo @[email protected]@@@@@ @[email protected]@@@@@ @[email protected]@@@@@ qqqqqAaq student Number (,(DuuJ(gr(r(r(, O Sisnature: COMPLETELY FILL IN BUBBLES correct: (D hcorrect:[email protected] C assl lnstructor Date: 1 , @@[email protected]@@@oo ,7 @@[email protected]@@@@oo 3 53 4 ,e @@@@@[email protected]@oo 54 5 30 @@[email protected]@@OO 80 @@@@@[email protected]@OO wg['xfi."\$I"ff,
Clarification 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
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
Picking up from last day … 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; }
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; }
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
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
Vector Allocation static allocation •e.g.

#### You've reached the end of your free preview.

Want to read all 48 pages?

• Spring '14

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern