Systems Programming and Computer Architecture ( )
|
|
- Rudolf Hood
- 5 years ago
- Views:
Transcription
1 Systems Group Department of Computer Science ETH Zürich Systems Programming and Computer Architecture ( ) Timothy Roscoe Herbstsemester
2 4: Pointers Computer Architecture and Systems Programming , Herbstsemester 2016 Timothy Roscoe 2
3 Process address space 0xffffffffffffffff OS gives each process an address space Contains process virtual memory, visible only to it 2 32 bytes on 32 bit host 2 64 bytes on 64 bit host (shown) code, data, libraries, stack, etc. AS x
4 When the OS loads a program, it: creates an address space inspects the executable file to see what s in it (lazily) copies regions of the file into the right place in the address space does any final linking, relocation, or other needed preparation Loading 0xffffffff 0xc x x Kernel virtual memory User stack (created at runtime) Memory-mapped region for shared libraries Run-time heap (created by malloc) Read/write segment (.data,.bss) Read-only segment (.init,.text,.rodata) Unused Memory inaccessible to user code Stack pointer brk Loaded from the executable file AS x
5 4.1: Recap: the stack Computer Architecture and Systems Programming , Herbstsemester 2016 Timothy Roscoe 5
6 Stack-Based Languages Languages supporting recursion (C, C#, Eiffel, Java..) Code must be reentrant Multiple simultaneous instantiations of single procedure Need to store state of each instantiation Arguments, local variables, return pointer Stack discipline State for given procedure needed for limited time From when called to when returns Callee returns before caller does Stack allocated in Frames state for single procedure activation 6
7 Call Chain Example yoo( ) who(); who( ) ami(); ami(); ami( ) ami(); Example call chain yoo who ami ami ami ami These are all different activations Procedure ami is recursive AS
8 Stack Frames Contents Local variables Return information Temporary space Previous Frame Management Space allocated when enter procedure Set-up code Deallocated when return Finish code Frame Pointer: Stack Pointer: Frame for proc Stack Top 8
9 Example Stack who( ) ami(); ami(); yoo who ami ami ami Frame Stack yoo who ami 9
10 Example Stack ami( ) ami(); yoo who ami ami ami yoo who ami ami ami Frame ami AS Stack
11 Example Stack ami( ) yoo who ami ami ami Frame yoo who ami ami Stack 11
12 Example Stack you( ) who(); yoo who ami ami ami Frame Stack yoo ami 12
13 4.2: Pointers in C Computer Architecture and Systems Programming , Herbstsemester 2016 Timothy Roscoe 13
14 Addresses and & &x produces the virtual address where the value of x is stored. You can use %p in printf() to print it out. addresses.c #include <stdio.h> int foo(int x) return x+1; int main(int argc, char *argv[]) int x, y; int a[2]; printf("x is at %p\n", &x); printf("y is at %p\n", &y); printf("a[0] is at %p\n", &a[0]); printf("a[1] is at %p\n", &a[1]); printf("foo is at %p\n", &foo); printf("main is at %p\n", &main); return 0; AS
15 Pointers type *name; // declare a pointer type *name = address; // declare + initialize a pointer A variable that contains a memory address points to somewhere in the process virtual address space AS 2016 int main(int argc, char **argv) int x = 42; int *p; // p is a pointer to an integer p = &x; // p now stores the address of x printf("x is %d\n", x); printf("&x is %p\n", &x); printf("p is %p\n", p); return 0; pointy.c
16 Dereferencing a pointer v = *pointer; *pointer = value; // dereference a pointer // dereference / assign dereference: access the memory referred to by a pointer #include <stdio.h> AS 2016 int main(int argc, char **argv) int x = 42; int *p; // p is a pointer to an integer p = &x; // p now stores the address of x printf("x is %d\n", x); *p = 99; printf("x is %d\n", x); return 0; deref.c
17 NULL a guaranteed-to-be-invalid memory location typeof(null) is void * In C on Linux: NULL is 0x (or 0x ) Any attempt to dereference NULL segmentation fault #include <stdio.h> AS 2016 int main(int argc, char *argv[]) int *p = NULL; *p = 1; // causes a segmentation fault return 0; segfault.c
18 Something curious Run this several times: #include <stdio.h> asr.c int main(int argc, char *argv[]) int x = 1; int *p = &x; AS 2016 printf( &x: %p; p: %p; &p: %p\n, &x, p, &p); return 0; troscoe@cixous:~$ gcc -Wall asr.c troscoe@cixous:~$./a.out &x: 0x7fff33b06314; p: 0x7fff33b06314; &p: 0x7fff33b06318 troscoe@cixous:~$./a.out &x: 0x7fffee820f34; p: 0x7fffee820f34; &p: 0x7fffee820f38 troscoe@cixous:~$./a.out &x: 0x7fff230d8b64; p: 0x7fff230d8b64; &p: 0x7fff230d8b68
19 Address Space Layout Randomization Linux randomizes: Base of stack Shared library locations Security feature We ll see some overflow attacks later Makes debugging tougher Kernel virtual memory User stack shared libraries Run-time heap Read/write segment (.data,.bss) Read-only segment (.init,.text,.rodata) Unused 0xffffffffffffffff 0x AS
20 Summary Every variable in C has: Name: what is it called? Address: where in memory is it? Type: how to interpret the value Value: what is stored at the address C pointers are variables that contain the addresses of other variables. Java has no pointers (only object references), C# has them only in unsafe code // px is a ptr to an integer int *px; // x is an integer int x; // px gets the address of x // or px points to x px = &x; // x gets the contents of // whatever x points to x = *px; 20
21 4.3: Box-and-arrow diagrams Computer Architecture and Systems Programming , Herbstsemester 2016 Timothy Roscoe 21
22 Box and arrow diagrams #include <stdio.h> int main(int argc, char **argv) int x = 1; int arr[3] = 2, 3, 4; int *p = &arr[1]; boxarrow.c printf("&x: %p; x: %d\n", &x, x); printf("&arr[0]: %p; arr[0]: %d\n", &arr[0], arr[0]); printf("&arr[2]: %p; arr[2]: %d\n", &arr[2], arr[2]); printf("&p: %p; p: %p; *p: %d\n", &p, p, *p); return 0; address name value 0x7fffbe90f854 x 1 0x7fffbe90f860 arr[0] 2 0x7fffbe90f864 arr[1] 3 0x7fffbe90f868 arr[2] 4 0x7fffbe90f858 p 0x7fffbe90f864 22
23 Box and arrow diagrams #include <stdio.h> int main(int argc, char **argv) int x = 1; int arr[3] = 2, 3, 4; int *p = &arr[1]; boxarrow.c printf("&x: %p; x: %d\n", &x, x); printf("&arr[0]: %p; arr[0]: %d\n", &arr[0], arr[0]); printf("&arr[2]: %p; arr[2]: %d\n", &arr[2], arr[2]); printf("&p: %p; p: %p; *p: %d\n", &p, p, *p); return 0; address name value 0x7fffbe90f868 arr[2] 4 0x7fffbe90f864 arr[1] 3 0x7fffbe90f860 arr[0] 2 0x7fffbe90f858 p 0x7fffbe90f864 0x7fffbe90f854 x 1 23 main() stack frame
24 Box and arrow diagrams #include <stdio.h> int main(int argc, char **argv) int x = 1; int arr[3] = 2, 3, 4; int *p = &arr[1]; boxarrow.c printf("&x: %p; x: %d\n", &x, x); printf("&arr[0]: %p; arr[0]: %d\n", &arr[0], arr[0]); printf("&arr[2]: %p; arr[2]: %d\n", &arr[2], arr[2]); printf("&p: %p; p: %p; *p: %d\n", &p, p, *p); return 0; address name value 0x7fffbe90f854 x 1 0x7fffbe90f860 arr[0] 2 0x7fffbe90f864 arr[1] 3 0x7fffbe90f868 arr[2] 4 0x7fffbe90f858 p 0x7fffbe90f864 24
25 Box and arrow diagrams #include <stdio.h> int main(int argc, char **argv) int x = 1; int arr[3] = 2, 3, 4; int *p = &arr[1]; int **dp = &p; boxarrow2.c *(*dp) += 1; p += 1; *(*dp) += 1; return 0; address name value 0x7fffbe90f854 x 1 0x7fffbe90f860 arr[0] 2 0x7fffbe90f864 arr[1] 4 0x7fffbe90f868 arr[2] 4 0x7fffbe90f848 dp 0x7fffbe90f858 0x7fffbe90f858 p 0x7fffbe90f864 25
26 Box and arrow diagrams #include <stdio.h> int main(int argc, char **argv) int x = 1; int arr[3] = 2, 3, 4; int *p = &arr[1]; int **dp = &p; boxarrow2.c *(*dp) += 1; p += 1; *(*dp) += 1; return 0; address name value 0x7fffbe90f854 x 1 0x7fffbe90f860 arr[0] 2 0x7fffbe90f864 arr[1] 4 0x7fffbe90f868 arr[2] 4 0x7fffbe90f848 dp 0x7fffbe90f858 0x7fffbe90f858 p 0x7fffbe90f868 26
27 Box and arrow diagrams #include <stdio.h> int main(int argc, char **argv) int x = 1; int arr[3] = 2, 3, 4; int *p = &arr[1]; int **dp = &p; *(*dp) += 1; p += 1; *(*dp) += 1; return 0; boxarrow2.c Pointers are typed: int *int_ptr; char *char_ptr; int **ptr_ptr; Pointer arithmetic follows pointer type address name value 0x7fffbe90f854 x 1 0x7fffbe90f860 arr[0] 2 0x7fffbe90f864 arr[1] 4 0x7fffbe90f848 0x7fffbe90f868 arr[2] 5 dp 0x7fffbe90f858 0x7fffbe90f858 p 0x7fffbe90f868 27
28 4.4: Pointer arithmetic Computer Architecture and Systems Programming , Herbstsemester 2016 Timothy Roscoe 28
29 Pointer arithmetic #include <stdio.h> int main(int argc, char **argv) int arr[3] = 1, 2, 3; int *int_ptr = &arr[0]; char *char_ptr = (char *) int_ptr; // more "type casting" later printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr += 1; printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr -= 2; // uh oh printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 1; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 2; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); arr[2] arr[1] arr[0] char_ptr int_ptr Stack (x86, 64-bit, little endian) return 0; pointerarithmetic.c int_ptr: 0x7fff19be2aa0; *int_ptr: 1 29
30 Pointer arithmetic #include <stdio.h> int main(int argc, char **argv) int arr[3] = 1, 2, 3; int *int_ptr = &arr[0]; char *char_ptr = (char *) int_ptr; // more "type casting" later printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr += 1; printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr -= 2; // uh oh printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 1; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 2; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); arr[2] arr[1] arr[0] char_ptr int_ptr Stack (x86, 64-bit, little endian) return 0; pointerarithmetic.c int_ptr: 0x7fff19be2aa0; *int_ptr: 1 30
31 Pointer arithmetic #include <stdio.h> int main(int argc, char **argv) int arr[3] = 1, 2, 3; int *int_ptr = &arr[0]; char *char_ptr = (char *) int_ptr; // more "type casting" later printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr += 1; printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr -= 2; // uh oh printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 1; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 2; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); arr[2] arr[1] arr[0] char_ptr int_ptr Stack (x86, 64-bit, little endian) return 0; pointerarithmetic.c int_ptr: 0x7fff19be2aa0; *int_ptr: 1 int_ptr: 0x7fff19be2aa4; *int_ptr: 2 31
32 Pointer arithmetic #include <stdio.h> int main(int argc, char **argv) int arr[3] = 1, 2, 3; int *int_ptr = &arr[0]; char *char_ptr = (char *) int_ptr; // more "type casting" later printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr += 1; printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr -= 2; // uh oh printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 1; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 2; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); arr[2] arr[1] arr[0] char_ptr int_ptr Stack (x86, 64-bit, little endian) char_ptr return 0; pointerarithmetic.c int_ptr: 0x7fff19be2aa0; *int_ptr: 1 int_ptr: 0x7fff19be2aa4; *int_ptr: 2 int_ptr: 0x7fff19be2abc; *int_ptr:
33 Pointer arithmetic #include <stdio.h> int main(int argc, char **argv) int arr[3] = 1, 2, 3; int *int_ptr = &arr[0]; char *char_ptr = (char *) int_ptr; // more "type casting" later printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr += 1; printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr -= 2; // uh oh printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 1; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 2; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); arr[2] arr[1] arr[0] char_ptr int_ptr Stack (x86, 64-bit, little endian) char_ptr return 0; pointerarithmetic.c char_ptr: 0x7fff19be2aa0; *char_ptr: 1 33
34 Pointer arithmetic #include <stdio.h> int main(int argc, char **argv) int arr[3] = 1, 2, 3; int *int_ptr = &arr[0]; char *char_ptr = (char *) int_ptr; // more "type casting" later printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr += 1; printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr -= 2; // uh oh printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 1; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 2; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); arr[2] arr[1] arr[0] char_ptr int_ptr Stack (x86, 64-bit, little endian) char_ptr return 0; pointerarithmetic.c char_ptr: 0x7fff19be2aa0; *char_ptr: 1 char_ptr: 0x7fff19be2aa1; *char_ptr: 0 char_ptr: 0x7fff19be2aa3; *char_ptr: 0 34
35 Pointer arithmetic #include <stdio.h> int main(int argc, char **argv) int arr[3] = 1, 2, 3; int *int_ptr = &arr[0]; char *char_ptr = (char *) int_ptr; // more "type casting" later printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr += 1; printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); int_ptr -= 2; // uh oh printf("int_ptr: %p; *int_ptr: %d\n", int_ptr, *int_ptr); printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 1; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); char_ptr += 2; printf("char_ptr: %p; *char_ptr: %d\n", char_ptr, *char_ptr); arr[2] arr[1] arr[0] char_ptr int_ptr Stack (x86, 64-bit, little endian) char_ptr return 0; pointerarithmetic.c char_ptr: 0x7fff19be2aa0; *char_ptr: 1 char_ptr: 0x7fff19be2aa1; *char_ptr: 0 char_ptr: 0x7fff19be2aa3; *char_ptr: 0 35
36 How much memory does a value take up? Depends on machine and compiler! Use: sizeof(type) or sizeof(value) Evaluates at compile time to size in bytes e.g. int nr = 1919; int size = sizeof(nr); 36
37 Summary No checks on where pointers point to! You can add an integer n to a pointer p. p now points to n objects further on Or back, in n is negative New value of p (not *p!) depends on type of *p sizeof() This looks a bit like array indexing 37
38 4.5: Arrays and pointers Computer Architecture and Systems Programming , Herbstsemester 2016 Timothy Roscoe 38
39 Arrays and pointers An array name in an expression is treated as a pointer to the first element of the array int a[10]; assert(a == &(a[0])); int get_1(int i) int *p = a; return p[i]; void set_1(int i, int v) int *p = a; p[i] = v; int get_2(int i) int *p = a; return *(p+i); void set_2(int i, int v) int *p = a; *(p+i) = v; int get_3(int i) int *p = a+i; return *p; void set_3(int i, int v) int *p = a+i; *p = v; AS
40 except when 1. The array s address is taken with & int a[10]; assert( &a == a ); 2. The array is a string literal initializer 3. The array is an operand of sizeof() int a[10]; assert( sizeof(a) == 10*sizeof(int)); assert( sizeof(&a[0]) == sizeof(int *)); 40
41 In fact A[i] is always rewritten *(A+i) in the compiler int a[10]; assert(a == &(a[0])); assert(a[5] == 5[a]); int get_2(int i) int *p = a; return i[p]; void set_2(int i, int v) int *p = a; i[p] = v; AS
42 An array name as a function parameter is a pointer The following are all precisely equivalent: int arrfun( int *myarray ) int arrfun( int myarray[] ) int arrfun( int myarray[42] ) Functions are also converted to pointers like this! 42
43 and can be called in any of these ways: int some_int; int *some_ptr; int some_array[10]; arrfun( &some_int ); arrfun( some_ptr ); arrfun( some_array ); arrfun( &some_array[i] ); all of which turn into pointers. 43
44 You can t rename an array Compile-time error: int array1[42], array2[42]; main(int argc, char *argv[]) array1 = array2; return 0; But this is OK (it s a pointer): void arrfun(int array[]) array = array2; 44
45 4.6: Passing by reference Computer Architecture and Systems Programming , Herbstsemester 2016 Timothy Roscoe 45
46 Pass-by-value C passes function arguments by value Callee gets a copy of the argument If callee modifies an argument, caller s copy isn t modified #include <stdio.h> void swap(int a, int b) int tmp = a; a = b; b = tmp; int main(int argc, char *argv[]) int a = 42, b = -7; swap(a, b); printf("a: %d, b: %d\n", a, b); return 0; brokenswap.c 46
47 Pass-by-reference You can use pointers to pass by reference Callee still receives a copy of the argument But it s now a pointer Pointer s value points to the variable in scope of the caller Callee can therefore modify a variable in the scope of the caller #include <stdio.h> void swap(int *a, int *b) int tmp = *a; *a = *b; *b = tmp; int main(int argc, char *argv[]) int a = 42, b = -7; swap(&a, &b); printf("a: %d, b: %d\n", a, b); return 0; swap.c 47
48 A simple strcpy() char *strcpy(char *dest, char *src) char *r = dest; while(*dest++ = *src++); return r; strcpy.c Lots going on here! Strings are arrays of characters terminated by null bytes Assigment is an expression, not a statement Non-zero values evaluate to true, zero evaluates to false Post-increment operators bind more tightly than pointer dereference A semicolon is statement terminator, not a separator This is also a dangerous function: use strncpy() instead. 48
49 C Pointer Declarations int *p int *p[13] int *(p[13]) int **p int (*p)[13] int *f() int (*f)() int (*(*f())[13])() p is a pointer to int p is an array[13] of pointer to int p is an array[13] of pointer to int p is a pointer to a pointer to an int p is a pointer to an array[13] of int f is a function returning a pointer to int f is a pointer to a function returning int f is a function returning ptr to an array[13] of pointers to functions returning int int (*(*x[3])())[5] x is an array[3] of pointers to functions returning pointers to array[5] of ints 49
CMPSC 311- Introduction to Systems Programming Module: Arrays and Pointers
CMPSC 311- Introduction to Systems Programming Module: Arrays and Pointers Professor Patrick McDaniel Fall 2014 Course notes Exam moved to Oct 1, 2014 Assignment #3 introduction section This Thur (9/25)
More informationPointers, Pointers, Pointers
Pointers, Pointers, Pointers CSE 333 Autumn 2018 Instructor: Hal Perkins Teaching Assistants: Tarkan Al-Kazily Renshu Gu Trais McGaha Harshita Neti Thai Pham Forrest Timour Soumya Vasisht Yifan Xu Administriia
More informationCSE 333 Lecture 3 - arrays, memory, pointers
CSE 333 Lecture 3 - arrays, memory, pointers Steve Gribble Department of Computer Science & Engineering University of Washington Administrivia HW 0.5 (a 4-question survey) - out today, due Monday HW 1.0
More informationPointers, Pointers, Pointers
Pointers, Pointers, Pointers CSE 333 Summer 2018 Instructor: Hal Perkins Teaching Assistants: Renshu Gu William Kim Soumya Vasisht Administrivia v Exercise 2 out today and due Monday morning v Exercise
More informationCSE 333 Lecture 2 - arrays, memory, pointers
CSE 333 Lecture 2 - arrays, memory, pointers Hal Perkins Department of Computer Science & Engineering University of Washington Administrivia 1 ex0 was due 30 minutes ago! Solution posted after class -
More informationAn Experience Like No Other. Stack Discipline Aug. 30, 2006
15-410 An Experience Like No Other Discipline Aug. 30, 2006 Bruce Maggs Dave Eckhardt Slides originally stolen from 15-213 15-410, F 06 Synchronization Registration If you're here but not registered, please
More informationStack Discipline Jan. 19, 2018
15-410 An Experience Like No Other Discipline Jan. 19, 2018 Dave Eckhardt Brian Railing Slides originally stolen from 15-213 1 15-410, S 18 Synchronization Registration The wait list will probably be done
More informationIntermediate Programming, Spring 2017*
600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general
More informationC: Pointers, Arrays, and strings. Department of Computer Science College of Engineering Boise State University. August 25, /36
Department of Computer Science College of Engineering Boise State University August 25, 2017 1/36 Pointers and Arrays A pointer is a variable that stores the address of another variable. Pointers are similar
More informationC: Pointers. C: Pointers. Department of Computer Science College of Engineering Boise State University. September 11, /21
Department of Computer Science College of Engineering Boise State University September 11, 2017 1/21 Pointers A pointer is a variable that stores the address of another variable. Pointers are similar to
More informationSystems I. Machine-Level Programming V: Procedures
Systems I Machine-Level Programming V: Procedures Topics abstraction and implementation IA32 stack discipline Procedural Memory Usage void swap(int *xp, int *yp) int t0 = *xp; int t1 = *yp; *xp = t1; *yp
More informationCS 61c: Great Ideas in Computer Architecture
Arrays, Strings, and Some More Pointers June 24, 2014 Review of Last Lecture C Basics Variables, functioss, control flow, types, structs Only 0 and NULL evaluate to false Pointers hold addresses Address
More informationMemory and Arrays. CSE 333 Spring Instructor: Justin Hsia
Memory and Arrays CSE 333 Spring 2018 Instructor: Justin Hsia Teaching Assistants: Danny Allen Dennis Shao Eddie Huang Kevin Bi Jack Xu Matthew Neldam Michael Poulain Renshu Gu Robby Marver Waylon Huang
More informationPointers (part 1) What are pointers? EECS We have seen pointers before. scanf( %f, &inches );! 25 September 2017
Pointers (part 1) EECS 2031 25 September 2017 1 What are pointers? We have seen pointers before. scanf( %f, &inches );! 2 1 Example char c; c = getchar(); printf( %c, c); char c; char *p; c = getchar();
More informationLecture 4: Outline. Arrays. I. Pointers II. III. Pointer arithmetic IV. Strings
Lecture 4: Outline I. Pointers A. Accessing data objects using pointers B. Type casting with pointers C. Difference with Java references D. Pointer pitfalls E. Use case II. Arrays A. Representation in
More informationArrays and Pointers in C. Alan L. Cox
Arrays and Pointers in C Alan L. Cox alc@rice.edu Objectives Be able to use arrays, pointers, and strings in C programs Be able to explain the representation of these data types at the machine level, including
More informationSYSC 2006 C Winter 2012
SYSC 2006 C Winter 2012 Pointers and Arrays Copyright D. Bailey, Systems and Computer Engineering, Carleton University updated Sept. 21, 2011, Oct.18, 2011,Oct. 28, 2011, Feb. 25, 2011 Memory Organization
More informationLecture 04 Introduction to pointers
Lecture 04 Introduction to pointers A pointer is an address in the memory. One of the unique advantages of using C is that it provides direct access to a memory location through its address. A variable
More informationCourse organization. Course introduction ( Week 1)
Course organization Course introduction ( Week 1) Code editor: Emacs Part I: Introduction to C programming language (Week 2-9) Chapter 1: Overall Introduction (Week 1-3) Chapter 2: Types, operators and
More informationUnderstanding Pointers
Division of Mathematics and Computer Science Maryville College Pointers and Addresses Memory is organized into a big array. Every data item occupies one or more cells. A pointer stores an address. A pointer
More informationCS107 Handout 08 Spring 2007 April 9, 2007 The Ins and Outs of C Arrays
CS107 Handout 08 Spring 2007 April 9, 2007 The Ins and Outs of C Arrays C Arrays This handout was written by Nick Parlante and Julie Zelenski. As you recall, a C array is formed by laying out all the elements
More informationSystems Programming and Computer Architecture ( )
Systems Group Department of Computer Science ETH Zürich Systems Programming and Computer Architecture (252-0061-00) Timothy Roscoe Herbstsemester 2016 AS 2016 Dynamic Memory Allocation 1 5: Dynamic memory
More informationReview: C Strings. A string in C is just an array of characters. Lecture #4 C Strings, Arrays, & Malloc
CS61C L4 C Pointers (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #4 C Strings, Arrays, & Malloc Albert Chae Instructor 2008-06-26 Review: C Strings A string in C is just an array
More informationC - Func(on, Pointer, Array. Zhaoguo Wang
C - Func(on, Pointer, Array Zhaoguo Wang A gigantic main loop https://github.com/qemu/qemu/blob/master/vl.c Function Readability Reusability Function int add(int a, int b) { int r = a + b; return r; name
More informationntroduction to C CS 2022: ntroduction to C nstructor: Hussam Abu-Libdeh (based on slides by Saikat Guha) Fall 2011, Lecture 1 ntroduction to C CS 2022, Fall 2011, Lecture 1 History of C Writing code in
More informationAnnouncements. assign0 due tonight. Labs start this week. No late submissions. Very helpful for assign1
Announcements assign due tonight No late submissions Labs start this week Very helpful for assign1 Goals for Today Pointer operators Allocating memory in the heap malloc and free Arrays and pointer arithmetic
More informationKurt Schmidt. October 30, 2018
to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed
More informationCS 61C: Great Ideas in Computer Architecture. C Arrays, Strings, More Pointers
CS 61C: Great Ideas in Computer Architecture C Arrays, Strings, More Pointers Instructor: Justin Hsia 6/20/2012 Summer 2012 Lecture #3 1 Review of Last Lecture C Basics Variables, Functions, Flow Control,
More informationThe output: The address of i is 0xbf85416c. The address of main is 0x80483e4. arrays.c. 1 #include <stdio.h> 3 int main(int argc, char **argv) 4 {
Memory A bit is a binary digit, either 0 or 1. A byte is eight bits, and can thus represent 256 unique values, such as 00000000 and 10010110. Computer scientists often think in terms of hexadecimal, rather
More informationA brief introduction to C programming for Java programmers
A brief introduction to C programming for Java programmers Sven Gestegård Robertz September 2017 There are many similarities between Java and C. The syntax in Java is basically
More informationMemory, Arrays & Pointers
1 Memory, Arrays & Pointers Memory int main() { char c; int i,j; double x; c i j x 2 Arrays Defines a block of consecutive cells int main() { int i; int a[3]; i a[0] a[1] a[2] Arrays - the [ ] operator
More informationCS61C Machine Structures. Lecture 5 C Structs & Memory Mangement. 1/27/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/
CS61C Machine Structures Lecture 5 C Structs & Memory Mangement 1/27/2006 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L05 C Structs (1) C String Standard Functions
More informationProgramming. Pointers, Multi-dimensional Arrays and Memory Management
Programming Pointers, Multi-dimensional Arrays and Memory Management Summary } Computer Memory } Pointers } Declaration, assignment, arithmetic and operators } Casting and printing pointers } Relationship
More informationArrays and Pointers. Arrays. Arrays: Example. Arrays: Definition and Access. Arrays Stored in Memory. Initialization. EECS 2031 Fall 2014.
Arrays Arrays and Pointers l Grouping of data of the same type. l Loops commonly used for manipulation. l Programmers set array sizes explicitly. EECS 2031 Fall 2014 November 11, 2013 1 2 Arrays: Example
More informationCS C Primer. Tyler Szepesi. January 16, 2013
January 16, 2013 Topics 1 Why C? 2 Data Types 3 Memory 4 Files 5 Endianness 6 Resources Why C? C is exteremely flexible and gives control to the programmer Allows users to break rigid rules, which are
More informationCS 11 C track: lecture 5
CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap Pointers (from last week) Address: location where data stored
More informationCS61C : Machine Structures
inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 5 C Memory Management Lecturer PSOE Dan Garcia www.cs.berkeley.edu/~ddgarcia CS61C L05 C Structures, Memory Management (1) 2005-01-28 The
More informationCS 31: Intro to Systems Pointers and Memory. Martin Gagne Swarthmore College February 16, 2016
CS 31: Intro to Systems Pointers and Memory Martin Gagne Swarthmore College February 16, 2016 So we declared a pointer How do we make it point to something? 1. Assign it the address of an existing variable
More informationProcedural programming with C
Procedural programming with C Dr. C. Constantinides Department of Computer Science and Software Engineering Concordia University Montreal, Canada August 11, 2016 1 / 77 Functions Similarly to its mathematical
More informationHigh-performance computing and programming Intro to C on Unix/Linux. Uppsala universitet
High-performance computing and programming Intro to C on Unix/Linux IT Uppsala universitet What is C? An old imperative language that remains rooted close to the hardware C is relatively small and easy
More informationCS61C Machine Structures. Lecture 4 C Structs & Memory Management. 9/5/2007 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/
CS61C Machine Structures Lecture 4 C Structs & Memory Management 9/5/2007 John Wawrzynek (www.cs.berkeley.edu/~johnw) www-inst.eecs.berkeley.edu/~cs61c/ CS 61C L04 C Structs (1) C String Standard Functions
More informationAgenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011
CS 61C: Great Ideas in Computer Architecture (Machine Structures) Introduction to C (Part II) Instructors: Randy H. Katz David A. Patterson http://inst.eecs.berkeley.edu/~cs61c/sp11 Spring 2011 -- Lecture
More informationLecture 2: C Programm
0 3 E CS 1 Lecture 2: C Programm ing C Programming Procedural thought process No built in object abstractions data separate from methods/functions Low memory overhead compared to Java No overhead of classes
More informationPROGRAMMAZIONE I A.A. 2017/2018
PROGRAMMAZIONE I A.A. 2017/2018 A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. DECLARING POINTERS POINTERS A pointer represents both
More informationunsigned char memory[] STACK ¼ 0x xC of address space globals function KERNEL code local variables
Graded assignment 0 will be handed out in section Assignment 1 Not that bad Check your work (run it through the compiler) Factorial Program Prints out ENTERING, LEAVING, and other pointers unsigned char
More informationProcesses. Johan Montelius KTH
Processes Johan Montelius KTH 2017 1 / 47 A process What is a process?... a computation a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other
More informationCS 31: Intro to Systems Pointers and Memory. Kevin Webb Swarthmore College October 2, 2018
CS 31: Intro to Systems Pointers and Memory Kevin Webb Swarthmore College October 2, 2018 Overview How to reference the location of a variable in memory Where variables are placed in memory How to make
More informationA process. the stack
A process Processes Johan Montelius What is a process?... a computation KTH 2017 a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other processes
More informationSystem Software Assignment 1 Runtime Support for Procedures
System Software Assignment 1 Runtime Support for Procedures Exercise 1: Nested procedures Some programming languages like Oberon and Pascal support nested procedures. 1. Find a run-time structure for such
More informationCS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor
CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static
More informationCSE 303: Concepts and Tools for Software Development
CSE 303: Concepts and Tools for Software Development Hal Perkins Winter 2009 Lecture 7 Introduction to C: The C-Level of Abstraction CSE 303 Winter 2009, Lecture 7 1 Welcome to C Compared to Java, in rough
More informationC Review. MaxMSP Developers Workshop Summer 2009 CNMAT
C Review MaxMSP Developers Workshop Summer 2009 CNMAT C Syntax Program control (loops, branches): Function calls Math: +, -, *, /, ++, -- Variables, types, structures, assignment Pointers and memory (***
More informationECE 15B COMPUTER ORGANIZATION
ECE 15B COMPUTER ORGANIZATION Lecture 13 Strings, Lists & Stacks Announcements HW #3 Due next Friday, May 15 at 5:00 PM in HFH Project #2 Due May 29 at 5:00 PM Project #3 Assigned next Thursday, May 19
More informationPointers. Part VI. 1) Introduction. 2) Declaring Pointer Variables. 3) Using Pointers. 4) Pointer Arithmetic. 5) Pointers and Arrays
EE105: Software Engineering II Part 6 Pointers page 1 of 19 Part VI Pointers 1) Introduction 2) Declaring Pointer Variables 3) Using Pointers 4) Pointer Arithmetic 5) Pointers and Arrays 6) Pointers and
More informationEM108 Software Development for Engineers
EE108 Section 6 Pointers page 1 of 20 EM108 Software Development for Engineers Section 6 - Pointers 1) Introduction 2) Declaring Pointer Variables 3) Using Pointers 4) Pointer Arithmetic 5) Pointers and
More informationCSE 333 Lecture 2 Memory
CSE 333 Lecture 2 Memory John Zahorjan Department of Computer Science & Engineering University of Washington Today s goals - some terminology - review of memory resources - reserving memory - type checking
More informationLecture 8: Pointer Arithmetic (review) Endianness Functions and pointers
CSE 30: Computer Organization and Systems Programming Lecture 8: Pointer Arithmetic (review) Endianness Functions and pointers Diba Mirza University of California, San Diego 1 Q: Which of the assignment
More informationFundamentals of Programming
Fundamentals of Programming Pointers Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) Pointers February 29, 2012 1
More informationOther C materials before pointer Common library functions [Appendix of K&R] 2D array, string manipulations. <stdlib.
1 The previous lecture Other C materials before pointer Common library functions [Appendix of K&R] 2D array, string manipulations Pointer basics 1 Common library functions [Appendix of K+R]
More informationArrays and Pointers. CSE 2031 Fall November 11, 2013
Arrays and Pointers CSE 2031 Fall 2013 November 11, 2013 1 Arrays l Grouping of data of the same type. l Loops commonly used for manipulation. l Programmers set array sizes explicitly. 2 Arrays: Example
More informationCS61, Fall 2012 Section 2 Notes
CS61, Fall 2012 Section 2 Notes (Week of 9/24-9/28) 0. Get source code for section [optional] 1: Variable Duration 2: Memory Errors Common Errors with memory and pointers Valgrind + GDB Common Memory Errors
More informationArrays Arrays and pointers Loops and performance Array comparison Strings. John Edgar 2
CMPT 125 Arrays Arrays and pointers Loops and performance Array comparison Strings John Edgar 2 Python a sequence of data access elements with [index] index from [0] to [len-1] dynamic length heterogeneous
More informationCPSC 213, Winter 2016, Term 2 Final Exam Solution Date: April 19, 2017; Instructor: Mike Feeley and Alan Wagner
CPSC 213, Winter 2016, Term 2 Final Exam Solution Date: April 19, 2017; Instructor: Mike Feeley and Alan Wagner 1 (4 marks) Variables and Memory. Consider the following code running on 32-bit, big-endian
More informationDynamic Allocation in C
Dynamic Allocation in C C Pointers and Arrays 1 The previous examples involved only targets that were declared as local variables. For serious development, we must also be able to create variables dynamically,
More informationDynamic Memory Allocation. Zhaoguo Wang
Dynamic Memory Allocation Zhaoguo Wang Why dynamic memory allocation? Do not know the size until the program runs (at runtime). #define MAXN 15213 int array[maxn]; int main(void) { int i, n; scanf("%d",
More informationCSE 333 Lecture 4 - malloc, free, struct, typedef
CSE 333 Lecture 4 - malloc, free, struct, typedef Administrivia HW1 is due on Friday, January 25th, 11:15am - see course overview web page for the late policy Be sure to check out the course discussion
More informationTutorial 1: Introduction to C Computer Architecture and Systems Programming ( )
Systems Group Department of Computer Science ETH Zürich Tutorial 1: Introduction to C Computer Architecture and Systems Programming (252-0061-00) Herbstsemester 2012 Goal Quick introduction to C Enough
More informationLanguage comparison. C has pointers. Java has references. C++ has pointers and references
Pointers CSE 2451 Language comparison C has pointers Java has references C++ has pointers and references Pointers Values of variables are stored in memory, at a particular location A location is identified
More informationWhen you add a number to a pointer, that number is added, but first it is multiplied by the sizeof the type the pointer points to.
Refresher When you add a number to a pointer, that number is added, but first it is multiplied by the sizeof the type the pointer points to. i.e. char *ptr1 = malloc(1); ptr1 + 1; // adds 1 to pointer
More informationFrom Java to C. Thanks to Randal E. Bryant and David R. O'Hallaron (Carnegie-Mellon University) for providing the basis for these slides
From Java to C Thanks to Randal E. Bryant and David R. O'Hallaron (Carnegie-Mellon University) for providing the basis for these slides 1 Outline Overview comparison of C and Java Good evening Preprocessor
More informationELEC 377 C Programming Tutorial. ELEC Operating Systems
ELE 377 Programming Tutorial Outline! Short Introduction! History & Memory Model of! ommon Errors I have seen over the years! Work through a linked list example on the board! - uses everything I talk about
More informationJagannath Institute of Management Sciences Lajpat Nagar. BCA II Sem. C Programming
Jagannath Institute of Management Sciences Lajpat Nagar BCA II Sem C Programming UNIT I Pointers: Introduction to Pointers, Pointer Notation,Decalaration and Initialization, Accessing variable through
More informationInformatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Puntatori Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 5, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction to C October
More informationCS 107 Lecture 5: Arrays. and Pointers in C. Monday, January 22, Stanford University. Computer Science Department
CS 107 Address Value Lecture 5: Arrays 8 and Pointers in C 0x128 3 0x120 Monday, January 22, 2018 9 0x118 Computer Systems Winter 2018-4 Stanford University 0x110 Computer Science Department 2 Reading:
More informationCSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community
CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu History and Evolution of Programming Languages 1. Explain the relationship between machine
More informationIn Java we have the keyword null, which is the value of an uninitialized reference type
+ More on Pointers + Null pointers In Java we have the keyword null, which is the value of an uninitialized reference type In C we sometimes use NULL, but its just a macro for the integer 0 Pointers are
More informationPIC 10A Pointers, Arrays, and Dynamic Memory Allocation. Ernest Ryu UCLA Mathematics
PIC 10A Pointers, Arrays, and Dynamic Memory Allocation Ernest Ryu UCLA Mathematics Pointers A variable is stored somewhere in memory. The address-of operator & returns the memory address of the variable.
More informationLecture 07 Debugging Programs with GDB
Lecture 07 Debugging Programs with GDB In this lecture What is debugging Most Common Type of errors Process of debugging Examples Further readings Exercises What is Debugging Debugging is the process of
More informationFUNCTIONS POINTERS. Pointers. Functions
Functions Pointers FUNCTIONS C allows a block of code to be separated from the rest of the program and named. These blocks of code or modules are called functions. Functions can be passed information thru
More informationC Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee
C Language Part 1 (Minor modifications by the instructor) References C for Python Programmers, by Carl Burch, 2011. http://www.toves.org/books/cpy/ The C Programming Language. 2nd ed., Kernighan, Brian,
More informationPointers. Pointers. Pointers (cont) CS 217
Pointers CS 217 Pointers Variables whose values are the addresses of variables Operations address of (reference) & indirection (dereference) * arithmetic +, - Declaration mimics use char *p; *p is a char,
More informationOutline. Lecture 1 C primer What we will cover. If-statements and blocks in Python and C. Operators in Python and C
Lecture 1 C primer What we will cover A crash course in the basics of C You should read the K&R C book for lots more details Various details will be exemplified later in the course Outline Overview comparison
More informationArrays and Pointers (part 1)
Arrays and Pointers (part 1) CSE 2031 Fall 2012 Arrays Grouping of data of the same type. Loops commonly used for manipulation. Programmers set array sizes explicitly. Arrays: Example Syntax type name[size];
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 9 Pointer Department of Computer Engineering 1/46 Outline Defining and using Pointers
More informationCS 61C: Great Ideas in Computer Architecture. Lecture 3: Pointers. Bernhard Boser & Randy Katz
CS 61C: Great Ideas in Computer Architecture Lecture 3: Pointers Bernhard Boser & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Agenda Pointers in C Arrays in C This is not on the test Pointer arithmetic
More informationLecture 3: C Programm
0 3 E CS 1 Lecture 3: C Programm ing Reading Quiz Note the intimidating red border! 2 A variable is: A. an area in memory that is reserved at run time to hold a value of particular type B. an area in memory
More informationSo far, system calls have had easy syntax. Integer, character string, and structure arguments.
Pointers Page 1 So far, system calls have had easy syntax Wednesday, September 30, 2015 10:45 AM Integer, character string, and structure arguments. But this is not always true. Today, we begin to explore
More informationCS 61C: Great Ideas in Computer Architecture C Pointers. Instructors: Vladimir Stojanovic & Nicholas Weaver
CS 61C: Great Ideas in Computer Architecture C Pointers Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/sp16 1 Agenda Pointers Arrays in C 2 Address vs. Value Consider
More informationBinary Representation. Decimal Representation. Hexadecimal Representation. Binary to Hexadecimal
Decimal Representation Binary Representation Can interpret decimal number 4705 as: 4 10 3 + 7 10 2 + 0 10 1 + 5 10 0 The base or radix is 10 Digits 0 9 Place values: 1000 100 10 1 10 3 10 2 10 1 10 0 Write
More informationDecimal Representation
Decimal Representation Can interpret decimal number 4705 as: 4 10 3 + 7 10 2 + 0 10 1 + 5 10 0 The base or radix is 10 Digits 0 9 Place values: 1000 100 10 1 10 3 10 2 10 1 10 0 Write number as 4705 10
More informationLab 1: Introduction to C Programming
CS342 Computer Security Handout # 2 Prof. Lyn Turbak September 13, 2010 Wellesley College Lab 1: Introduction to C Programming Reading: Hacking, 0x210 0x240 Overview Later in the course, we will study
More informationPointers. Pointer References
Pointers Pointers are variables whose values are the addresses of other variables Basic operations address of (reference) indirection (dereference) Suppose x and y are integers, p is a pointer to an integer:
More informationLecture 03 Bits, Bytes and Data Types
Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics
More informationExercise Session 2 Systems Programming and Computer Architecture
Systems Group Department of Computer Science ETH Zürich Exercise Session 2 Systems Programming and Computer Architecture Herbstsemester 216 Agenda Linux vs. Windows Working with SVN Exercise 1: bitcount()
More informationCSE 333. Lecture 4 - malloc, free, struct, typedef. Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington
CSE 333 Lecture 4 - malloc, free, struct, typedef Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington Administrivia 1 New exercise out today, due Friday morning
More informationExercise Session 3 Systems Programming and Computer Architecture
Systems Group Department of Computer Science ETH Zürich Exercise Session 3 Systems Programming and Computer Architecture Herbstsemester 2016 Agenda Review of Exercise 2 More on C-Programming Outlook to
More informationHacking in C. Pointers. Radboud University, Nijmegen, The Netherlands. Spring 2019
Hacking in C Pointers Radboud University, Nijmegen, The Netherlands Spring 2019 Allocation of multiple variables Consider the program main(){ char x; int i; short s; char y;... } What will the layout of
More informationPointer Arithmetic and Lexical Scoping. CS449 Spring 2016
Pointer Arithmetic and Lexical Scoping CS449 Spring 2016 Review Pitfall 1 from previous lecture void foo(char *s) { s = "World"; int main() { char *str = "Hello"; foo(str); printf("%s\n", str); return
More informationMemory. What is memory? How is memory organized? Storage for variables, data, code etc. Text (Code) Data (Constants) BSS (Global and static variables)
Memory Allocation Memory What is memory? Storage for variables, data, code etc. How is memory organized? Text (Code) Data (Constants) BSS (Global and static variables) Text Data BSS Heap Stack (Local variables)
More informationData Types and Computer Storage Arrays and Pointers. K&R, chapter 5
Data Types and Computer Storage Arrays and Pointers K&R, chapter 5 Fundamental Data Types Most fundamental types are numeric (integer): - char - signed or unsigned - short int - signed or unsigned - int
More information