Http://proglit.com/. the c language BY SA 1972 by Ken Thompson and Dennis Ritchie.

April 5, 2018 | Author: Anonymous | Category: Documents
Report this link


Description

Slide 1http://proglit.com/ Slide 2the c language Slide 3BY SA Slide 4Slide 51972 by Ken Thompson and Dennis Ritchie Slide 6developed concurrently with Unix C++ and Objective-C in 1980’s ANSI C89, C90, and C99 GCC (Gnu Compiler Collection) MSVC (Microsoft Visual C++) Slide 7http://proglit.com/ Slide 8imperative/procedural statically typed weakly typed Slide 9control of memory explicitly manipulate individual bytes “portable assembly” compact data manual allocation Slide 10calling convention assembly from C C from assembly (how functions are called in machine code) Slide 11systems programming (operating systems, device drivers) performance-sensitive code (games, media players) Slide 12http://proglit.com/ Slide 13basic data types char 1-byte signed integer int n-byte signed integer float single-precision floating- point double double-precision floating-point Slide 14declarations type name; int monkey; float zebra; Slide 15functions returnType name(parameters) {body} Slide 16int square(int n) { return n * n; } int cube(int n) { return square(n) * n; } Slide 17char foo(int a, float b, float c) { … } Slide 18casting (type) expression int x = 35; foo((char) x); Slide 19http://proglit.com/ Slide 20!0// 1 !1// 0 !0.6// 0 !3// 0 !-76.5// 0 Slide 21void roger(int x) { if (x == 3) { int z = 9; foo(z); } else { bar(z); // z does not exist } ack(z); // z does not exist } Slide 22Slide 23int main() { printf(“Hello, world!”); return 0; } Slide 24http://proglit.com/ Slide 25value variables float a = 9.3; Slide 26pointers (a data type representing an address) int *foo; double *bar; char *ack; Slide 27reference operator &lvalue int i; int *p; p = &i; char c; int *p; p = &c; // error Slide 28reference operator &lvalue int i; int *p; p = &i; Slide 29dereference operator *pointer int i = 3; int *p; p = &i; i = *p + 2; Slide 30int i; int *p; p = &i; *p = 6; Slide 31http://proglit.com/ Slide 32pointer arithmetic int i; int *p; p = &i + 2; i = *p; Slide 33can subtract a pointer from a pointer can’t add a pointer to a pointer Slide 34char *p; p = (char *) 0xB000FFFF; char c = *p; Slide 35int *p; p = 0; if (p) { … } // false Slide 36pointer comparisons == != >< >=


Comments

Copyright © 2025 UPDOCS Inc.