Lecture 12: October 21, 2019
Reading: C text, §8, 9
Due: Extra Credit #1: due October 21, 2019; Homework #2, due October 24, 2019
- Greetings and felicitations!
- General: there are a couple of aids to learning the Bourne-Again shell, bash(1)
- Homework 2: I posted an announcement to answer some of the questions.
- Extra Credit assignment, problem 2; you just need to give the command, not execute it; but you can replace “/usr” with “/home” if you like.
- Operators
- Comma operator ,; use while(printf("> "), scanf("%d", &x) != EOF) and y = 3; x = y++, 20
- Order of evaluation of function arguments; use i = 10; f(i, ++i) and f(i, i++)
- C characters
- Characters as integers and numbers (caesar-enc.c, caesar-dec.c)
- String library functions
- Prototypes in include file string.h
- String length: strlen(str)
- String copy: strcpy(dest, src); strncpy(dest, src, number_chars)
- String catenation: strcat(dest, src); strncat(dest, src, number_chars)
- String comparison: strcmp(dest, src); strncmp(dest, src, number_chars)
- Recursive greatest common divisor
- Go through Euclidean algorithm for computing gcd
- Walk through function gcd, with m = 4 and n = 6
- Do it again with m = 126 and n = 28
- Go through program gcd.c