CS 330 Lecture 11 – Slightly Above the Machine with C
Agenda
- what ?s
- what does assembly not do?
- things that languages provide:
- binding names to data
- type systems
- scope
- abstraction
- compilers and interpreters
- some C exercises
- atoi
- makepath
- blackjack scoring
TODO
- Read chapter 1 through 1.5 in Programming Language Pragmatics. Bonus 1/4 sheet.
- Start Savage, homework 1. Later-week submission deadline is February 28.
Code
atoi.c
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
const char s[] = "124213";
int s_as_int = 0;
int magnitude = 1;
while () {
s_as_int += (s[i] - '0') * magnitude;
magnitude *= 10;
}
/* '6' - '0' */
return 0;
}
Haiku
on the multiplicity of languages
Could we have just one?
As long as it’s strong enough—
To express others
Could we have just one?
As long as it’s strong enough—
To express others