TELE402. Internetworking. TELE402 Lecture 1 Protocol Layering 1

Size: px
Start display at page:

Download "TELE402. Internetworking. TELE402 Lecture 1 Protocol Layering 1"

Transcription

1 TELE402 Internetworking TELE402 Lecture 1 Protocol Layering 1

2 People Lecturer Dr. Zhiyi Huang Phone: Office: 1.26 Owheo Building Teaching Assistant Kai-Cheung Leung Phone: Office: 2.55 Owheo Building TELE402 Lecture 1 Protocol Layering 2

3 Assessment Labs 20% Assignments 30% Exam (Have to get 40 out of 100 to pass) 50% TELE402 Lecture 1 Protocol Layering 3

4 Textbooks Internetworking with TCP/IP, Vol. 1, Principles, Protocols, and Architectures (5th ed), D.E. Comer, Prentice Hall Unix Network Programming, Vol. 1, The Sockets Networking API (3rd ed), W.R. Stevens, B. Fenner, A.M. Rudoff, Addison Wesley TELE402 Lecture 1 Protocol Layering 4

5 About the Course Lectures & reading Internetworking with TCP/IP Socket API Labs Programming network applications Assignments TELE402 Lecture 1 Protocol Layering 5

6 Overview This lecture The C programming language Source: A good C programming book Protocol layering Source: Chapter 10 for reading Next lecture TCP and UDP TELE402 Lecture 1 Protocol Layering 6

7 Functions - 1 Remember: no classes or methods in C. C is case-sensitive. Functions are the main abstraction mechanism and represent an operation to be performed more than once. Functions have a name, arguments and a return type. If a function does not produce a value, it has a return type of void. The actions of a function are expressed in the body that is enclosed in curly braces -- { } A function is invoked whenever the call operator ( () ) is applied to the function s name. TELE402 Lecture 1 Protocol Layering 7

8 Functions - 2 Every C program must have a function named, main. This function is called to run the program. The main function returns an int or void. #include <stdio.h> int main() { printf( hello, world\n ); } TELE402 Lecture 1 Protocol Layering 8

9 Functions - 3 There are many standard functions already defined that are part of the C language. These functions are stored in libraries. The first line of the previous program (#include <stdio.h>) tells the preprocessor to include the standard input/output library. TELE402 Lecture 1 Protocol Layering 9

10 Functions - 4 int area( int length, int width ) { return length * width; } Functions must be declared before they are called. An expression including a call to the area function: 2 * area( 5, 7) + 25; TELE402 Lecture 1 Protocol Layering 10

11 Functions 5 (scope) Variables that are declared inside a function are called, automatic, and are local to that function. It is possible to define external variables that are external to all functions. The scope of an external variable lasts from the point at which it is declared to the end of the file. If an external variable is to be used and has been defined in a different source file, then an extern declaration is required. TELE402 Lecture 1 Protocol Layering 11

12 Functions 6 (scope) Automatic variables are so-named, because they appear and disappear automatically when a function is called. The values of function parameters are also automatic. They are copies of the values of the variables that were passed to the function in a function call. This is known as call-by-value parameter passing. TELE402 Lecture 1 Protocol Layering 12

13 Example #include <stdio.h> int sum( int a, int b); // function prototype at the start of the file int main() { int x = 4, y = 5; int total = sum( x, y ); // function call printf( The sum of 4 and 5 is %d, total); } int sum( int a, int b ) // call-by-value { return( a + b ); } TELE402 Lecture 1 Protocol Layering 13

14 Memory and addresses int x = 5, y = 10; float f = 12.5, g = 9.8; char c = z ; (the addresses are at 2100, 2104, etc.) z TELE402 Lecture 1 Protocol Layering 14

15 Pointers - 1 A variable can contain a value of a data type, such as an integer or a float. It can also contain a memory address - it can contain the address of another variable. float x; // data variable float *xaddr // pointer variable x xaddr any float TELE402 Lecture 1 Protocol Layering some address 15

16 Pointers - 2 xaddr = &x; // & = address-of operator x xaddr??? *xaddr = 4.4; // * = dereference operator x 4.4 xaddr TELE402 Lecture 1 Protocol Layering 16

17 Pointers - 3 x = 3.3; x xaddr Now xaddr points to x. If x has its value changed, the dereferencing of xaddr will yield that new value. TELE402 Lecture 1 Protocol Layering 17

18 Pointers - 4 int x = 1, y = 8; int *ip, *iq; ip = &x; // ip now points to x y = *ip; // y is now 1 *ip = 6; // x is now 6; iq = ip; // iq points to what ip points to TELE402 Lecture 1 Protocol Layering 18

19 Pointer arithmetic int i, j, k; int *ip; ip = &i; *ip = *ip + 2; // add 2 to i ip = ip + 2; // add to the address of // i, which is the // address ip contains. The addition of 2 to a pointer increases the value of the address it contains by the size of two objects of its type. TELE402 Lecture 1 Protocol Layering 19

20 There s a problem here: #include <stdio.h> void swap( int, int ); Why use pointers? main() { int num1 = 5, num2 = 10; swap( num1, num2 ); printf( num1 = %d and num2 = %d\n, num1, num2); } void swap(int n1, int n2) { int temp; // passed by value } temp = n1; n1 = n2; n2 = temp; TELE402 Lecture 1 Protocol Layering 20

21 Use of pointers helps #include <stdio.h> void swap( int*, int* ); main() { int num1 = 5, num2 = 10; swap( &num1, &num2 ); printf( num1 = %d and num2 = %d\n, num1, num2); } void swap( int *n1, int *n2 ) // passed by reference { int temp; } temp = *n1; *n1 = *n2; *n2 = temp; TELE402 Lecture 1 Protocol Layering 21

22 Basic input/output If you want to use the standard input/output library, you must have #include <stdio.h> before the first usage. The simplest function reads one character from the standard input (usually the keyboard): int getchar( void ); (It returns the next input character each time it is called.) int putchar( int c ) puts the character c on the standard output, which is usually the screen. TELE402 Lecture 1 Protocol Layering 22

23 Formatted output printf is somewhat complicated, but enables you to produce formatted output. int printf ( char *format, arg 1, arg 2, ) The format string contains two types of objects: ordinary characters (which are just copied to the output stream) and special conversion specifications. Each conversion begins with a %. \ is used for special characters. Recall: printf( num1 = %d and num2 = %d\n, num1, num2); TELE402 Lecture 1 Protocol Layering 23

24 Formatted input The function scanf is the input analog to printf and uses many of the same conversion facilities (in the opposite direction). int scanf( char *format, arg 1, arg 2, ) Note that each of the input arguments must be a pointer indicating where the converted input is supposed to be stored. TELE402 Lecture 1 Protocol Layering 24

25 Type conversion At the machine level, we just have a collection of bits. Changing one predefined type to another will change some properties, but not the underlying bits. Some conversions are safe and some are unsafe. The programmer can request a conversion by performing a cast. TELE402 Lecture 1 Protocol Layering 25

26 Casting There are two ways to request a cast: type (expr) (type) expr What happens when we do this? double (int ( ) ); Some conversions are safe on some machines, but not on others (it depends on the word size of the machine), because an int is usually the same size as either a short or a long, but not both. TELE402 Lecture 1 Protocol Layering 26

27 Implicit (automatic) conversions Assigning a value to an object converts the value to the type of that object. void ff( int ); int val = ; // converts to int 3 ff( ); // converts to int 3 The widest data type in an arithmetic expression is the target conversion type: val ; // double (but val is still an int) TELE402 Lecture 1 Protocol Layering 27

28 Pointer conversions int ival; int *pi = 0; char *pc = 0; void *pv; // can convert others to this, // but a void* pointer cannot // be dereferenced directly. pv = pi; // ok pc = pv; // ok *pc = *pv; // error TELE402 Lecture 1 Protocol Layering 28

29 Arrays - 1 An array is a collection of ordered data items, all belonging to the same type. For example, declare: int values[9]; values[0] = 107; values[5] = 33; The first array index is always 0. values[0] values[1] values[2] values[3] values[4] values[5] values[6] values[7] values[8] TELE402 Lecture 1 Protocol Layering 29

30 Arrays - 2 #include <stdio.h> void main(void) { int myary[12]; int index, sum = 0; // 12 cells // Initialize array before use for (index = 0; index < 12; index++) { myary[index] = index; } } for (index = 0; index < 12; index++) { sum += myary[index]; // sum array elements } printf( The sum is %d, sum ); TELE402 Lecture 1 Protocol Layering 30

31 Arrays - 3 We can have multidimensional arrays: int points[3][4]; points[1][2]; What is points[1,2]? (wrong!) Initialize arrays: int counters[5] = { 0, 0, 0, 0, 4 }; char letters[] = { a, b, c, d, e }; Notice the second example. If the array is initialized, you don t have to specify the array size. The compiler will figure it out. TELE402 Lecture 1 Protocol Layering 31

32 Example: convert number base int main () { char base_digits[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }; int converted_number[64]; long int num_to_convert; int next_digit, base, index = 0; // get the number and base printf( Number to be converted? ); scanf( %ld, &num_to_convert); printf( Base? ); scanf( %i, &base); TELE402 Lecture 1 Protocol Layering 32

33 } // convert to the indicated base do { converted_number[index] = num_to_convert % base; ++index; num_to_convert = num_to_convert / base; } while ( num_to_convert!= 0 ); // display the results in reverse order printf( Converted number = ); for ( --index; index >= 0; --index ) { next_digit = converted_number[index]; printf( %c, base_digits[next_digit]); } printf( \n ); TELE402 Lecture 1 Protocol Layering 33

34 More about arrays The name of the array by itself, is v like a pointer to the first element of the array This means that we can write *(v+i) and that has exactly the same meaning as v[i]. (In fact when the C compiler sees v[i], it converts it to *(v+i).) v[0] v[1] v[2] v[3] H e l l But there is one difference -- an array v[4] o v[5] name is not a variable.! TELE402 Lecture 1 Protocol Layering 34

35 Character strings We can write char word[] = { H, e, l, l, o,! }; or char word[] = { H, e, l, l, o,!, \0 }; The special character at the end is useful for searching down the end of character strings to find the end point. The second declaration can be duplicated by char word[] = Hello! ; Character string constants in C are automatically terminated by the null ( \0 ) character. What is the length of this string array? TELE402 Lecture 1 Protocol Layering 35

36 Character strings Function to concatenate two character strings: void concat( char result[], char str1[], char str2[]) { } int i, j; for( i=0; str1[i]!= \0; ++i ) result[i] = str1[i]; for( j=0; str2[j]!= \0; ++j ) result[i+j] = str2[j]; result[i+j] = \0 ; TELE402 Lecture 1 Protocol Layering 36

37 Useful string functions char *strcat(s1, s2) append s2 onto s1 char *strncat(s1,s2, n) append only n characters char *strchr (s, c) search s for character c int strcmp (s1, s2) compare s1, s2 char *strcpy (s1, s2) copy s2 to s1 char *strrchr (s, c) search s for last occurrence of c int strstr (s1, s2) search s1 for first occurrence of s2 int strlen (s) count number of characters in s TELE402 Lecture 1 Protocol Layering 37

38 Arrays When an array (or character string) is passed to a function, it is passed by reference. int main() { void concat( char result[], char str1[], char str2[]) char s1[] = { Hoo }; char sw[] = { Ha! }; char se[20]; concat(s3, s1, s2); printf( %s\n, s3); } TELE402 Lecture 1 Protocol Layering 38

39 Arrays and strings Why does this work for copying strings? while (*p++ = *q++) C performs no array boundary checks. This means that you can overrun the end of an array, without the compiler complaining. This is the cause of many runtime errors!!! TELE402 Lecture 1 Protocol Layering 39

40 Structs - 1 #include <stdio.h> struct birthday { int month; int day; int year; }; // note semicolon int main() { struct birthday bd; bd.day=1; bd.month=1; bd.year=1977; printf( My birthday is %d/%d/%d, bd.day, bd.month, bd.year); } TELE402 Lecture 1 Protocol Layering 40

41 Structs - 2 struct person { char name[80]; int age; float height; struct { int month; int day; int year; } birth; }; // elements can be different types // embedded struct struct person me; struct person class[60]; me.birth.year=1977; class[0].name= Jack ; class[0].birth.year = 1971;... TELE402 Lecture 1 Protocol Layering 41

42 Structs - 3 So structs are like records (in Pascal) or classes in Java (without methods, though). When structs are passed to functions as arguments, they are passed by value, unlike arrays, which are passed by reference. TELE402 Lecture 1 Protocol Layering 42

43 Dynamic memory allocation The C compiler automatically allocates memory for the variables that are declared. But sometimes we need to allocate memory during runtime, as we need it. malloc is a memory allocation function. It takes one argument: the number of bytes to allocate. It returns a pointer to void, so you have to cast it to what s been allocated. sizeof is an operator that is useful here. It tells you the size of a data type. TELE402 Lecture 1 Protocol Layering 43

44 Dynamic memory allocation Suppose you want to allocate enough memory to store 1,000 integers. You can int *intptr intptr = (int *) malloc (1000 * sizeof (int)); The cast TELE402 Lecture 1 Protocol Layering 44

45 Memory management After you are finished with the memory space allocated to a pointer q using malloc, you should free it up by calling: free(q); This will release the memory space allocated to q. TELE402 Lecture 1 Protocol Layering 45

46 Operations on Files Open a file before you use it fp = fopen( t.txt, r ); Read data from an opened file fread(buffer, 1024, 2, fp); Write data into an opened file fwrite(data, 512, 2, fp); Close an opened file fclose(fp); TELE402 Lecture 1 Protocol Layering 46

47 Low-level file operations open, close, read, write, ioctl open(char *name, int flags); close(int fd); read(int fd, void *buf, size_t count); write(int fd, void *buf, size_t count); ioctl(int fd, int request, char *argp); Use man 2 func to find out the details. TELE402 Lecture 1 Protocol Layering 47

48 Protocol Layering Why layering? Hardware failure Network congestion Packet delay or loss Data corruption Data duplication and reordering TELE402 Lecture 1 Protocol Layering 48

49 Layering principle Layering principle Layered protocols are designed so that layer n at the destination receives exactly the same object sent by layer n at the source Pros and cons Complexity, process time, memory usage Modularity, simplicity, interoperability, robustness, security, cost effective TELE402 Lecture 1 Protocol Layering 49

50 ISO OSI model Seven layers TCP/IP model Five layers PDU and SDU Layered models Protocol data unit: payload and meta-data (headers) Service data unit: PDU that has been passed down to the lower layer PDU of a layer is the SDU of the layer below. TELE402 Lecture 1 Protocol Layering 50

51 Application layer PDUs in TCP/IP Messages, request/response Transport layer UPD datagrams, TCP segments Network layer IP packets Data link layer Data frames (Ethernet frames) TELE402 Lecture 1 Protocol Layering 51

52 Multiplexing/demultiplexing Multiplexing All data streams are placed into the same network entity for transfer Demultiplexing Separate the different streams at the receiver end Data link layer IP module, ARP module, RARP module IP layer TCP, UDP, ICMP, SCTP, DCCP Transport (Socket) layer based on ports smtpd, sshd, httpd, TELE402 Lecture 1 Protocol Layering 52

53 Kernel/user space Application is in user space Socket, TCP, UDP, IP, data link (network drivers) are in the kernel space. Applications access network protocols through socket API (system calls) TELE402 Lecture 1 Protocol Layering 53

ARRAYS(II Unit Part II)

ARRAYS(II Unit Part II) ARRAYS(II Unit Part II) Array: An array is a collection of two or more adjacent cells of similar type. Each cell in an array is called as array element. Each array should be identified with a meaningful

More information

C programming basics T3-1 -

C programming basics T3-1 - C programming basics T3-1 - Outline 1. Introduction 2. Basic concepts 3. Functions 4. Data types 5. Control structures 6. Arrays and pointers 7. File management T3-2 - 3.1: Introduction T3-3 - Review of

More information

To declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array as follows

To declare an array in C, a programmer specifies the type of the elements and the number of elements required by an array as follows Unti 4: C Arrays Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type An array is used to store a collection of data, but it is often more useful

More information

Contents. A Review of C language. Visual C Visual C++ 6.0

Contents. A Review of C language. Visual C Visual C++ 6.0 A Review of C language C++ Object Oriented Programming Pei-yih Ting NTOU CS Modified from www.cse.cuhk.edu.hk/~csc2520/tuto/csc2520_tuto01.ppt 1 2 3 4 5 6 7 8 9 10 Double click 11 12 Compile a single source

More information

CS113: Lecture 7. Topics: The C Preprocessor. I/O, Streams, Files

CS113: Lecture 7. Topics: The C Preprocessor. I/O, Streams, Files CS113: Lecture 7 Topics: The C Preprocessor I/O, Streams, Files 1 Remember the name: Pre-processor Most commonly used features: #include, #define. Think of the preprocessor as processing the file so as

More information

Lectures 5-6: Introduction to C

Lectures 5-6: Introduction to C Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

Lectures 5-6: Introduction to C

Lectures 5-6: Introduction to C Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most

More information

Language comparison. C has pointers. Java has references. C++ has pointers and references

Language 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 information

ECEN 449 Microprocessor System Design. Review of C Programming

ECEN 449 Microprocessor System Design. Review of C Programming ECEN 449 Microprocessor System Design Review of C Programming 1 Objectives of this Lecture Unit Review C programming basics Refresh es programming g skills s 2 1 Basic C program structure # include

More information

Goals of this Lecture

Goals of this Lecture I/O Management 1 Goals of this Lecture Help you to learn about: The Unix stream concept Standard C I/O functions Unix system-level functions for I/O How the standard C I/O functions use the Unix system-level

More information

C-LANGUAGE CURRICULAM

C-LANGUAGE CURRICULAM C-LANGUAGE CURRICULAM Duration: 2 Months. 1. Introducing C 1.1 History of C Origin Standardization C-Based Languages 1.2 Strengths and Weaknesses Of C Strengths Weaknesses Effective Use of C 2. C Fundamentals

More information

mith College Computer Science CSC270 Spring 2016 Circuits and Systems Lecture Notes, Week 11 Dominique Thiébaut

mith College Computer Science CSC270 Spring 2016 Circuits and Systems Lecture Notes, Week 11 Dominique Thiébaut mith College Computer Science CSC270 Spring 2016 Circuits and Systems Lecture Notes, Week 11 Dominique Thiébaut dthiebaut@smithedu Outline A Few Words about HW 8 Finish the Input Port Lab! Revisiting Homework

More information

COP 3223 Final Review

COP 3223 Final Review COP 3223 Final Review Jennifer Brown December 2, 2018 1 Introduction 1.1 Variables I. How can we store data in a program? A. Which of these are valid names for variables? i. 9length ii. hello iii. IamASuperCoolName

More information

I/O Management! Goals of this Lecture!

I/O Management! Goals of this Lecture! I/O Management! 1 Goals of this Lecture! Help you to learn about:" The Unix stream concept" Standard C I/O functions" Unix system-level functions for I/O" How the standard C I/O functions use the Unix

More information

I/O Management! Goals of this Lecture!

I/O Management! Goals of this Lecture! I/O Management! 1 Goals of this Lecture! Help you to learn about:" The Unix stream concept" Standard C I/O functions" Unix system-level functions for I/O" How the standard C I/O functions use the Unix

More information

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.

C BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ. C BOOTCAMP DAY 2 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Pointers 2 Pointers Pointers are an address in memory Includes variable addresses,

More information

Computer Programming. C Array is a collection of data belongings to the same data type. data_type array_name[array_size];

Computer Programming. C Array is a collection of data belongings to the same data type. data_type array_name[array_size]; Arrays An array is a collection of two or more adjacent memory cells, called array elements. Array is derived data type that is used to represent collection of data items. C Array is a collection of data

More information

BSM540 Basics of C Language

BSM540 Basics of C Language BSM540 Basics of C Language Chapter 4: Character strings & formatted I/O Prof. Manar Mohaisen Department of EEC Engineering Review of the Precedent Lecture To explain the input/output functions printf()

More information

ONE DIMENSIONAL ARRAYS

ONE DIMENSIONAL ARRAYS LECTURE 14 ONE DIMENSIONAL ARRAYS Array : An array is a fixed sized sequenced collection of related data items of same data type. In its simplest form an array can be used to represent a list of numbers

More information

CS 222: Pointers and Manual Memory Management

CS 222: Pointers and Manual Memory Management CS 222: Pointers and Manual Memory Management Chris Kauffman Week 4-1 Logistics Reading Ch 8 (pointers) Review 6-7 as well Exam 1 Back Today Get it in class or during office hours later HW 3 due tonight

More information

High Performance Computing in C and C++

High Performance Computing in C and C++ High Performance Computing in C and C++ Rita Borgo Computer Science Department, Swansea University Summary Introduction to C Writing a simple C program Compiling a simple C program Running a simple C program

More information

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

More information

Arrays and Pointers in C. Alan L. Cox

Arrays 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 information

Introduction to string

Introduction to string 1 Introduction to string String is a sequence of characters enclosed in double quotes. Normally, it is used for storing data like name, address, city etc. ASCII code is internally used to represent string

More information

Pointers (part 1) What are pointers? EECS We have seen pointers before. scanf( %f, &inches );! 25 September 2017

Pointers (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 information

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information Laboratory 2: Programming Basics and Variables Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information 3. Comment: a. name your program with extension.c b. use o option to specify

More information

(13-2) Dynamic Data Structures I H&K Chapter 13. Instructor - Andrew S. O Fallon CptS 121 (November 17, 2017) Washington State University

(13-2) Dynamic Data Structures I H&K Chapter 13. Instructor - Andrew S. O Fallon CptS 121 (November 17, 2017) Washington State University (13-2) Dynamic Data Structures I H&K Chapter 13 Instructor - Andrew S. O Fallon CptS 121 (November 17, 2017) Washington State University Dynamic Data Structures (1) Structures that expand and contract

More information

ECEN 449 Microprocessor System Design. Review of C Programming. Texas A&M University

ECEN 449 Microprocessor System Design. Review of C Programming. Texas A&M University ECEN 449 Microprocessor System Design Review of C Programming 1 Objectives of this Lecture Unit Review C programming basics Refresh programming skills 2 Basic C program structure # include main()

More information

Procedural Programming & Fundamentals of Programming

Procedural Programming & Fundamentals of Programming Procedural Programming & Fundamentals of Programming Exercise 3 (SS 2018) 29.05.2018 What will I learn in the 4. exercise Pointer (and a little bit about memory allocation) Structure Strings and String

More information

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010

CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010 CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011 Lectures 1-22 Moaaz Siddiq Asad Ali Latest Mcqs MIDTERM EXAMINATION Spring 2010 Question No: 1 ( Marks: 1 ) - Please

More information

8. Characters, Strings and Files

8. Characters, Strings and Files REGZ9280: Global Education Short Course - Engineering 8. Characters, Strings and Files Reading: Moffat, Chapter 7, 11 REGZ9280 14s2 8. Characters and Arrays 1 ASCII The ASCII table gives a correspondence

More information

Section 3: File I/O, JSON, Generics. Meghan Cowan

Section 3: File I/O, JSON, Generics. Meghan Cowan Section 3: File I/O, JSON, Generics Meghan Cowan POSIX Family of standards specified by the IEEE Maintains compatibility across variants of Unix-like OS Defines API and standards for basic I/O: file, terminal

More information

BLM2031 Structured Programming. Zeyneb KURT

BLM2031 Structured Programming. Zeyneb KURT BLM2031 Structured Programming Zeyneb KURT 1 Contact Contact info office : D-219 e-mail zeynebkurt@gmail.com, zeyneb@ce.yildiz.edu.tr When to contact e-mail first, take an appointment What to expect help

More information

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

C 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 information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information

Chapter 5. Section 5.1 Introduction to Strings. CS 50 Hathairat Rattanasook

Chapter 5. Section 5.1 Introduction to Strings. CS 50 Hathairat Rattanasook Chapter 5 Section 5.1 Introduction to Strings CS 50 Hathairat Rattanasook "Strings" In computer science a string is a sequence of characters from the underlying character set. In C a string is a sequence

More information

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

COP 3223 Introduction to Programming with C - Study Union - Fall 2017 COP 3223 Introduction to Programming with C - Study Union - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................

More information

High Performance Programming Programming in C part 1

High Performance Programming Programming in C part 1 High Performance Programming Programming in C part 1 Anastasia Kruchinina Uppsala University, Sweden April 18, 2017 HPP 1 / 53 C is designed on a way to provide a full control of the computer. C is the

More information

C: Pointers, Arrays, and strings. Department of Computer Science College of Engineering Boise State University. August 25, /36

C: 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 information

Pointer Basics. Lecture 13 COP 3014 Spring March 28, 2018

Pointer Basics. Lecture 13 COP 3014 Spring March 28, 2018 Pointer Basics Lecture 13 COP 3014 Spring 2018 March 28, 2018 What is a Pointer? A pointer is a variable that stores a memory address. Pointers are used to store the addresses of other variables or memory

More information

mith College Computer Science CSC352 Week #7 Spring 2017 Introduction to C Dominique Thiébaut

mith College Computer Science CSC352 Week #7 Spring 2017 Introduction to C Dominique Thiébaut mith College CSC352 Week #7 Spring 2017 Introduction to C Dominique Thiébaut dthiebaut@smith.edu Learning C in 2 Hours D. Thiebaut Dennis Ritchie 1969 to 1973 AT&T Bell Labs Close to Assembly Unix Standard

More information

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been

More information

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

COP 3223 Introduction to Programming with C - Study Union - Fall 2017 COP 3223 Introduction to Programming with C - Study Union - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................

More information

Basic and Practice in Programming Lab7

Basic and Practice in Programming Lab7 Basic and Practice in Programming Lab7 Variable and Its Address (1/2) What is the variable? Abstracted representation of allocated memory Having address & value Memory address 10 0x00000010 a int a = 10;

More information

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types

More information

CSC 2400: Computer Systems. Arrays and Strings in C

CSC 2400: Computer Systems. Arrays and Strings in C CSC 2400: Computer Systems Arrays and Strings in C Lecture Overview Arrays! List of elements of the same type Strings! Array of characters ending in \0! Functions for manipulating strings 1 Arrays: C vs.

More information

Arrays and Pointers. CSE 2031 Fall November 11, 2013

Arrays 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 information

Intermediate Programming, Spring 2017*

Intermediate 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 information

Lecture07: Strings, Variable Scope, Memory Model 4/8/2013

Lecture07: Strings, Variable Scope, Memory Model 4/8/2013 Lecture07: Strings, Variable Scope, Memory Model 4/8/2013 Slides modified from Yin Lou, Cornell CS2022: Introduction to C 1 Outline Review pointers New: Strings New: Variable Scope (global vs. local variables)

More information

Lecture 3: C Programm

Lecture 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 information

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world

gcc hello.c a.out Hello, world gcc -o hello hello.c hello Hello, world alun@debian:~$ gcc hello.c alun@debian:~$ a.out Hello, world alun@debian:~$ gcc -o hello hello.c alun@debian:~$ hello Hello, world alun@debian:~$ 1 A Quick guide to C for Networks and Operating Systems

More information

EC 413 Computer Organization

EC 413 Computer Organization EC 413 Computer Organization C/C++ Language Review Prof. Michel A. Kinsy Programming Languages There are many programming languages available: Pascal, C, C++, Java, Ada, Perl and Python All of these languages

More information

Chapter 8 - Characters and Strings

Chapter 8 - Characters and Strings 1 Chapter 8 - Characters and Strings Outline 8.1 Introduction 8.2 Fundamentals of Strings and Characters 8.3 Character Handling Library 8.4 String Conversion Functions 8.5 Standard Input/Output Library

More information

The C Programming Language Part 4. (with material from Dr. Bin Ren, William & Mary Computer Science, and

The C Programming Language Part 4. (with material from Dr. Bin Ren, William & Mary Computer Science, and The C Programming Language Part 4 (with material from Dr. Bin Ren, William & Mary Computer Science, and www.cpp.com) 1 Overview Basic Concepts of Pointers Pointers and Arrays Pointers and Strings Dynamic

More information

Lecture 10: Potpourri: Enum / struct / union Advanced Unix #include function pointers

Lecture 10: Potpourri: Enum / struct / union Advanced Unix #include function pointers ....... \ \ \ / / / / \ \ \ \ / \ / \ \ \ V /,----' / ^ \ \.--..--. / ^ \ `--- ----` / ^ \. ` > < / /_\ \. ` / /_\ \ / /_\ \ `--' \ /. \ `----. / \ \ '--' '--' / \ / \ \ / \ / / \ \ (_ ) \ (_ ) / / \ \

More information

Outline. Lecture 1 C primer What we will cover. If-statements and blocks in Python and C. Operators in Python and C

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

C for Java Programmers 1. Last Week. Overview of the differences between C and Java. The C language (keywords, types, functies, etc.

C for Java Programmers 1. Last Week. Overview of the differences between C and Java. The C language (keywords, types, functies, etc. C for Java Programmers 1 Last Week Very short history of C Overview of the differences between C and Java The C language (keywords, types, functies, etc.) Compiling (preprocessor, compiler, linker) C for

More information

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli COMS W3101 Programming Language: C++ (Fall 2015) ramana@cs.columbia.edu Lecture-2 Overview of C continued C character arrays Functions Structures Pointers C++ string class C++ Design, difference with C

More information

CSC 2400: Computer Systems. Arrays and Strings in C

CSC 2400: Computer Systems. Arrays and Strings in C CSC 2400: Computer Systems Arrays and Strings in C Lecture Overview Arrays! List of elements of the same type Strings! Array of characters ending in \0! Functions for manipulating strings 1 Arrays in C

More information

CSC231 C Tutorial Fall 2018 Introduction to C

CSC231 C Tutorial Fall 2018 Introduction to C mith College CSC231 C Tutorial Fall 2018 Introduction to C Dominique Thiébaut dthiebaut@smith.edu Learning C in 4 Installments! Dennis Ritchie 1969 to 1973 AT&T Bell Labs Close to Assembly Unix Standard

More information

Computers Programming Course 5. Iulian Năstac

Computers Programming Course 5. Iulian Năstac Computers Programming Course 5 Iulian Năstac Recap from previous course Classification of the programming languages High level (Ada, Pascal, Fortran, etc.) programming languages with strong abstraction

More information

Model Viva Questions for Programming in C lab

Model Viva Questions for Programming in C lab Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous

More information

G52CPP C++ Programming Lecture 3. Dr Jason Atkin

G52CPP C++ Programming Lecture 3. Dr Jason Atkin G52CPP C++ Programming Lecture 3 Dr Jason Atkin E-Mail: jaa@cs.nott.ac.uk 1 Revision so far C/C++ designed for speed, Java for catching errors Java hides a lot of the details (so can C++) Much of C, C++

More information

Running a C program Compilation Python and C Variables and types Data and addresses Functions Performance. John Edgar 2

Running a C program Compilation Python and C Variables and types Data and addresses Functions Performance. John Edgar 2 CMPT 125 Running a C program Compilation Python and C Variables and types Data and addresses Functions Performance John Edgar 2 Edit or write your program Using a text editor like gedit Save program with

More information

CSCI 171 Chapter Outlines

CSCI 171 Chapter Outlines Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures

More information

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9 Fundamental of C Programming Unit I: Q1. What will be the value of the following expression? (2017) A + 9 Q2. Write down the C statement to calculate percentage where three subjects English, hindi, maths

More information

C: Pointers. C: Pointers. Department of Computer Science College of Engineering Boise State University. September 11, /21

C: 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 information

Object-Oriented Programming

Object-Oriented Programming iuliana@cs.ubbcluj.ro Babes-Bolyai University 2018 Overview 1 2 3 4 5 6 7 I No beard, no belly, no guru... Ken Thompson (B), Dennis Ritchie (C) - UNIX Bjarne Stroustrup (C++) James Gosling (Java) Figure:

More information

advanced data types (2) typedef. today advanced data types (3) enum. mon 23 sep 2002 defining your own types using typedef

advanced data types (2) typedef. today advanced data types (3) enum. mon 23 sep 2002 defining your own types using typedef today advanced data types (1) typedef. mon 23 sep 2002 homework #1 due today homework #2 out today quiz #1 next class 30-45 minutes long one page of notes topics: C advanced data types dynamic memory allocation

More information

Arrays and Pointers. Arrays. Arrays: Example. Arrays: Definition and Access. Arrays Stored in Memory. Initialization. EECS 2031 Fall 2014.

Arrays 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 information

COMP26120: Algorithms and Imperative Programming. Lecture 5: Program structuring, Java vs. C, and common mistakes

COMP26120: Algorithms and Imperative Programming. Lecture 5: Program structuring, Java vs. C, and common mistakes COMP26120: Algorithms and Imperative Programming Lecture 5: Program structuring, Java vs. C, and common mistakes Lecture outline Program structuring Functions (defining a functions, passing arguments and

More information

Object Oriented Pragramming (22316)

Object Oriented Pragramming (22316) Chapter 1 Principles of Object Oriented Programming (14 Marks) Q1. Give Characteristics of object oriented programming? Or Give features of object oriented programming? Ans: 1. Emphasis (focus) is on data

More information

A function is a named piece of code that performs a specific task. Sometimes functions are called methods, procedures, or subroutines (like in LC-3).

A function is a named piece of code that performs a specific task. Sometimes functions are called methods, procedures, or subroutines (like in LC-3). CIT Intro to Computer Systems Lecture # (//) Functions As you probably know from your other programming courses, a key part of any modern programming language is the ability to create separate functions

More information

C mini reference. 5 Binary numbers 12

C mini reference. 5 Binary numbers 12 C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char

More information

Chapter 8 Character Arrays and Strings

Chapter 8 Character Arrays and Strings Chapter 8 Character Arrays and Strings INTRODUCTION A string is a sequence of characters that is treated as a single data item. String constant: String constant example. \ String constant example.\ \ includes

More information

Strings. Arrays of characters. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY

Strings. Arrays of characters. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY Strings Arrays of characters Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY 1 Basics Strings A string is a sequence of characters treated as a group We have already

More information

SYSC 2006 C Winter String Processing in C. D.L. Bailey, Systems and Computer Engineering, Carleton University

SYSC 2006 C Winter String Processing in C. D.L. Bailey, Systems and Computer Engineering, Carleton University SYSC 2006 C Winter 2012 String Processing in C D.L. Bailey, Systems and Computer Engineering, Carleton University References Hanly & Koffman, Chapter 9 Some examples adapted from code in The C Programming

More information

COP 3223 Final Review

COP 3223 Final Review COP 3223 Final Review Jennifer Brown December 2, 2018 1 Introduction 1.1 Variables I. How can we store data in a program? Initializing variables with data types A. Which of these are valid names for variables?

More information

AN OVERVIEW OF C, PART 3. CSE 130: Introduction to Programming in C Stony Brook University

AN OVERVIEW OF C, PART 3. CSE 130: Introduction to Programming in C Stony Brook University AN OVERVIEW OF C, PART 3 CSE 130: Introduction to Programming in C Stony Brook University FANCIER OUTPUT FORMATTING Recall that you can insert a text field width value into a printf() format specifier:

More information

Sir Syed University of Engineering and Technology. Computer Programming & Problem Solving ( CPPS ) Pointers. Chapter No 7

Sir Syed University of Engineering and Technology. Computer Programming & Problem Solving ( CPPS ) Pointers. Chapter No 7 Computer Programming & Problem Solving ( CPPS ) Chapter No 7 Sir Syed University of Engineering & Technology Computer Engineering Department University Road, Karachi-75300, PAKISTAN Muzammil Ahmad Khan

More information

Advanced C Programming Topics

Advanced C Programming Topics Introductory Medical Device Prototyping Advanced C Programming Topics, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Operations on Bits 1. Recall there are 8

More information

Why learn C (after Java)? C for Java programmers. What does this C program do? Simple Example. Goals of this tutorial

Why learn C (after Java)? C for Java programmers. What does this C program do? Simple Example. Goals of this tutorial Why learn C (after Java)? C for Java programmers With Thanks to Indranil Gupta & Cornell Both high-level and low-level language Better control of low-level mechanisms Performance better than Java (Unix,

More information

Procedural Programming

Procedural Programming Exercise 5 (SS 2016) 28.06.2016 What will I learn in the 5. exercise Strings (and a little bit about pointer) String functions in strings.h Files Exercise(s) 1 Home exercise 4 (3 points) Write a program

More information

The TCP Protocol Stack

The TCP Protocol Stack The TCP Protocol Stack Michael Brockway February 16, 2018 Introduction - Layered archtecture Networking software is desgined in a layered fashion The bottom layer is the services offered by the underlying

More information

Lecture 12 CSE July Today we ll cover the things that you still don t know that you need to know in order to do the assignment.

Lecture 12 CSE July Today we ll cover the things that you still don t know that you need to know in order to do the assignment. Lecture 12 CSE 110 20 July 1992 Today we ll cover the things that you still don t know that you need to know in order to do the assignment. 1 The NULL Pointer For each pointer type, there is one special

More information

Compiling and Running a C Program in Unix

Compiling and Running a C Program in Unix CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 95 ] Compiling and Running a C Program in Unix Simple scenario in which your program is in a single file: Suppose you want to name

More information

Week 6 Part 1. Kyle Dewey. Monday, July 30, 12

Week 6 Part 1. Kyle Dewey. Monday, July 30, 12 Week 6 Part 1 Kyle Dewey Overview Announcement repeat Pre-lab #5 Pointers Arrays Exam #1 Lingering Questions +3 points on exam Pre-lab #5 Pointers Pointers Data that points to other data In my humble opinion,

More information

2/28/2018. Overview. The C Programming Language Part 4. Pointers. Pointers. Pointers. Pointers

2/28/2018. Overview. The C Programming Language Part 4. Pointers. Pointers. Pointers. Pointers Overview The C Programming Language Part 4 (with material from Dr. Bin Ren, William & Mary Computer Science, and www.cpp.com) Basic Concepts of and Arrays and Strings Dynamic Memory Allocation 1 2 pointer

More information

Processes often need to communicate. CSCB09: Software Tools and Systems Programming. Solution: Pipes. Recall: I/O mechanisms in C

Processes often need to communicate. CSCB09: Software Tools and Systems Programming. Solution: Pipes. Recall: I/O mechanisms in C 2017-03-06 Processes often need to communicate CSCB09: Software Tools and Systems Programming E.g. consider a shell pipeline: ps wc l ps needs to send its output to wc E.g. the different worker processes

More information

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level

More information

today cs3157-fall2002-sklar-lect05 1

today cs3157-fall2002-sklar-lect05 1 today homework #1 due on monday sep 23, 6am some miscellaneous topics: logical operators random numbers character handling functions FILE I/O strings arrays pointers cs3157-fall2002-sklar-lect05 1 logical

More information

CSCI 6610: Intermediate Programming / C Chapter 12 Strings

CSCI 6610: Intermediate Programming / C Chapter 12 Strings ... 1/26 CSCI 6610: Intermediate Programming / C Chapter 12 Alice E. Fischer February 10, 2016 ... 2/26 Outline The C String Library String Processing in C Compare and Search in C C++ String Functions

More information

Lecture 4: Outline. Arrays. I. Pointers II. III. Pointer arithmetic IV. Strings

Lecture 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 information

Midterm Examination # 2 Wednesday, March 18, Duration of examination: 75 minutes STUDENT NAME: STUDENT ID NUMBER:

Midterm Examination # 2 Wednesday, March 18, Duration of examination: 75 minutes STUDENT NAME: STUDENT ID NUMBER: Page 1 of 8 School of Computer Science 60-141-01 Introduction to Algorithms and Programming Winter 2015 Midterm Examination # 2 Wednesday, March 18, 2015 ANSWERS Duration of examination: 75 minutes STUDENT

More information

Arrays and Strings. Antonio Carzaniga. February 23, Faculty of Informatics Università della Svizzera italiana Antonio Carzaniga

Arrays and Strings. Antonio Carzaniga. February 23, Faculty of Informatics Università della Svizzera italiana Antonio Carzaniga Arrays and Strings Antonio Carzaniga Faculty of Informatics Università della Svizzera italiana February 23, 2015 Outline General memory model Definition and use of pointers Invalid pointers and common

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 11: Memory, Files and Bitoperations (yaseminb@kth.se) Overview Overview Lecture 11: Memory, Files and Bit operations Main function; reading and writing Bitwise Operations Lecture 11: Memory, Files

More information

Write a C program using arrays and structure

Write a C program using arrays and structure 03 Arrays and Structutes 3.1 Arrays Declaration and initialization of one dimensional, two dimensional and character arrays, accessing array elements. (10M) 3.2 Declaration and initialization of string

More information

Principles of C and Memory Management

Principles of C and Memory Management COMP281 Lecture 9 Principles of C and Memory Management Dr Lei Shi Last Lecture Today Pointer to Array Pointer Arithmetic Pointer with Functions struct Storage classes typedef union String struct struct

More information

C Syntax Arrays and Loops Math Strings Structures Pointers File I/O. Final Review CS Prof. Jonathan Ventura. Prof. Jonathan Ventura Final Review

C Syntax Arrays and Loops Math Strings Structures Pointers File I/O. Final Review CS Prof. Jonathan Ventura. Prof. Jonathan Ventura Final Review CS 2060 Variables Variables are statically typed. Variables must be defined before they are used. You only specify the type name when you define the variable. int a, b, c; float d, e, f; char letter; //

More information