Macros and Preprocessor. CGS 3460, Lecture 39 Apr 17, 2006 Hen-I Yang

Size: px
Start display at page:

Download "Macros and Preprocessor. CGS 3460, Lecture 39 Apr 17, 2006 Hen-I Yang"

Transcription

1 Macros and Preprocessor CGS 3460, Lecture 39 Apr 17, 2006 Hen-I Yang

2 Previously Operations on Linked list (Create and Insert)

3 Agenda Linked List (More insert, lookup and delete) Preprocessor

4 Linked List Operations Start a list Create a node Insert Search Query Print

5 Build a Linked List (I) Build a structure representing a node struct athlete { float speed; struct athlete * next; }; Initialize the node struct athelete *first = NULL;

6 Build a linked list: Create a node allocate memory for the node storing data into the node; insert the node into the list struct athlete *new_player; new_player = malloc(sizeof(struct athelete)); (*new_player).speed = 9.90; new_player next = NULL; first = new_player;

7 Insert a node: insert in the front new_player = malloc(sizeof(struct athelete)); new_player speed = 9.85; new_player next = first next; first = new_player;

8 Insert a node: insert at the end new_player = malloc(sizeof(struct athelete)); new_player speed = 10.10; new_player next = NULL; (first next) next = new_player;

9 Search and Delete Search: for (p = first; p!= NULL; p = p next) {. } Delete (almost reverse of insertion): locating the node to be deleted (see search a linked list) altering the previous node to bypass the deleted node calling free to reclaim the space occupied by the deleted node What to do to print everything out? (exercise)

10 Insert a node: insert in between new_player = malloc(sizeof(struct athelete)); new_player speed = 10.00; new_player next = NULL; struct athelete * q; for (p = first; p!= NULL; p = p next) { if (p speed > 10.00) { new_player next = q next; q next = new_player; break; } q = p; }

11 Pointer to Functions Pass as an argument in other function Exception handling More flexible (and abstract) programming int (*f) (int); (a function declaration, not definition) Example: void qsort(void * base, size_t nmemb, size_t size, int (*compare) (const void *, const void *));

12 Preprocessors Directives (#include, #define) are handled by preprocessor Preprocessing is handled prior to compilation preprocessor compiler C program Modified C prog Object Code Powerful, but can be hard to debug Recommended to be used carefully and moderately

13 Preprocessor Directives Macro definition #define, #undef File inclusion #include Conditional Compilation #if, #ifdef, #ifndef, #elseif, #else Others #error, #line, #pragma

14 More about Directives Directives always begin with # Directives can appear anywhere in the program Comments can be on the same line as a directive No need for = No need for ; Customary use upper case as constant name

15 Why use Macro? Primary Reasons It makes programs easier to read It makes programs easier to modify It helps avoid inconsistencies and typographical errors Other Reasons Making minor changes to the syntax of C (e.g. BEGIN, END instead of {}) Renaming Types (#define BOOL int) Controlling conditional compilation (#define DEGUB, empty replacement is ok)

16 Parameterized Macros #define identifier {x 1, x 2,,x n } replacement-list #define MAX(x, y) ((x)>(y)?(x):(y)) #define IS_EVEN(n) ((n)%2== 0) #define getchar() (getc(stdin))

17 Compare Parameterized Macros to Functions + Usually for simple functions + The program may be slightly faster, no preparation and runtime overhead + Generic and not restricted to the types of the functions + shorthand - compiled code will usually be larger, each invocation result in one copy - arguments not type checked - cannot use pointers to a macro - may evaluate its arguments more than once n = MAX(i++, j) n = ((i++)>y?(i++):y) - hard to debug - try avoid anything that comes with side effects

18 Rules for Macros A macro s replacement list may contain other macros Preprocessor replaces only entire tokens, not portions of tokens macro definition normally remains in effect until the end of the file in which it appears (that is, scope does not apply) macro may not be defined twice unless the definition is identical to the old one macros may be undefined by #undef directive

19 Questions about Macros Why do we usually include () in the macro definitions? How to create longer macros? Why is Macro easy to result in errors?

20 Conditional compilation #if expression #if defined expression #indef #inudef #elif and #else

21 Use of conditional compilation Write programs that are portable to several machines or operating systems #if defined(windows) #elif defined(linux) #elif defined(solaris) Writing programs that can be compiled differently by different compilers Providing a default definition for a macro #ifndef BUFFER_SIZE #define BUFFER_SIZE 256 #endif Temporarily disabling code that contains comments, especially useful when nesting comments

22 Summary Linked List (More insert, lookup and delete) Preprocessor and Macros

23 Before you go Read Section and Chapter 14 Exercise: How to delete a node and print the content of nodes in a linked list. Exercise:14.1, 14.3, 14.4, Homework 6 submission deadline this Friday (April 21 st ) at 11:59 pm

Have examined process Creating program Have developed program Written in C Source code

Have examined process Creating program Have developed program Written in C Source code Preprocessing, Compiling, Assembling, and Linking Introduction In this lesson will examine Architecture of C program Introduce C preprocessor and preprocessor directives How to use preprocessor s directives

More information

Conditional Compilation

Conditional Compilation Conditional Compilation printf() statements cab be inserted code for the purpose of displaying debug information during program testing. Once the program is debugged and accepted as "working'', it is desirable

More information

Chapter 7: Preprocessing Directives

Chapter 7: Preprocessing Directives Chapter 7: Preprocessing Directives Outline We will only cover these topics in Chapter 7, the remain ones are optional. Introduction Symbolic Constants and Macros Source File Inclusion Conditional Compilation

More information

OBJECT ORIENTED PROGRAMMING USING C++

OBJECT ORIENTED PROGRAMMING USING C++ OBJECT ORIENTED PROGRAMMING USING C++ Chapter 17 - The Preprocessor Outline 17.1 Introduction 17.2 The #include Preprocessor Directive 17.3 The #define Preprocessor Directive: Symbolic Constants 17.4 The

More information

CSE 374 Programming Concepts & Tools. Brandon Myers Winter 2015 C: Linked list, casts, the rest of the preprocessor (Thanks to Hal Perkins)

CSE 374 Programming Concepts & Tools. Brandon Myers Winter 2015 C: Linked list, casts, the rest of the preprocessor (Thanks to Hal Perkins) CSE 374 Programming Concepts & Tools Brandon Myers Winter 2015 C: Linked list, casts, the rest of the preprocessor (Thanks to Hal Perkins) Linked lists, trees, and friends Very, very common data structures

More information

Appendix A. The Preprocessor

Appendix A. The Preprocessor Appendix A The Preprocessor The preprocessor is that part of the compiler that performs various text manipulations on your program prior to the actual translation of your source code into object code.

More information

C for Engineers and Scientists: An Interpretive Approach. Chapter 7: Preprocessing Directives

C for Engineers and Scientists: An Interpretive Approach. Chapter 7: Preprocessing Directives Chapter 7: Preprocessing Directives Introduction Preprocessing Affect program preprocessing and execution Capabilities Inclusion of additional C source files Definition of symbolic constants and macros

More information

CS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1. W hat are Keywords? Keywords are certain reserved words that have standard and pre-defined meaning in C. These keywords can be used only for their

More information

CSE 374 Programming Concepts & Tools

CSE 374 Programming Concepts & Tools CSE 374 Programming Concepts & Tools Hal Perkins Fall 2017 Lecture 8 C: Miscellanea Control, Declarations, Preprocessor, printf/scanf 1 The story so far The low-level execution model of a process (one

More information

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead. Chapter 9: Rules Chapter 1:Style and Program Organization Rule 1-1: Organize programs for readability, just as you would expect an author to organize a book. Rule 1-2: Divide each module up into a public

More information

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things. A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators

More information

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

COMP322 - Introduction to C++ Lecture 02 - Basics of C++ COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.

More information

Gabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming

Gabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming 1 2 CMPE 013/L Pre Processor Commands Gabriel Hugh Elkaim Spring 2013 3 Introduction Preprocessing Affect program preprocessing and execution Capabilities Inclusion of additional C source files Definition

More information

Errors During Compilation and Execution Background Information

Errors During Compilation and Execution Background Information Errors During Compilation and Execution Background Information Preprocessor Directives and Compilation #define - defines a macro, identified by . During compilation, all instances of

More information

Problem Solving and 'C' Programming

Problem Solving and 'C' Programming Problem Solving and 'C' Programming Targeted at: Entry Level Trainees Session 15: Files and Preprocessor Directives/Pointers 2007, Cognizant Technology Solutions. All Rights Reserved. The information contained

More information

CSE 374 Programming Concepts & Tools

CSE 374 Programming Concepts & Tools CSE 374 Programming Concepts & Tools Hal Perkins Fall 2017 Lecture 13 C: The Rest of the Preprocessor 1 Administrivia Midterm exam Wednesday, here Topics: everything up to hw4 (including gdb concepts,

More information

#include. Practical C Issues: #define. #define Macros. Example. #if

#include. Practical C Issues: #define. #define Macros. Example. #if #include Practical C Issues: Preprocessor Directives, Typedefs, Multi-file Development, and Makefiles Jonathan Misurda jmisurda@cs.pitt.edu Copies the contents of the specified file into the current file

More information

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above

More information

Unit 4 Preprocessor Directives

Unit 4 Preprocessor Directives 1 What is pre-processor? The job of C preprocessor is to process the source code before it is passed to the compiler. Source Code (test.c) Pre-Processor Intermediate Code (test.i) Compiler The pre-processor

More information

Contents Lecture 3. C Preprocessor, Chapter 11 Declarations, Chapter 8. Jonas Skeppstedt Lecture / 44

Contents Lecture 3. C Preprocessor, Chapter 11 Declarations, Chapter 8. Jonas Skeppstedt Lecture / 44 Contents Lecture 3 C Preprocessor, Chapter 11 Declarations, Chapter 8 Jonas Skeppstedt (js@cs.lth.se) Lecture 3 2014 1 / 44 C Preprocessor Predefined macros Macro replacement Conditional inclusion Source

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

COMP322 - Introduction to C++ Lecture 01 - Introduction

COMP322 - Introduction to C++ Lecture 01 - Introduction COMP322 - Introduction to C++ Lecture 01 - Introduction Robert D. Vincent School of Computer Science 6 January 2010 What this course is Crash course in C++ Only 14 lectures Single-credit course What this

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

Object Oriented Design

Object Oriented Design Object Oriented Design Chapter 9 Initializing a non-static data member in the class definition is a syntax error 1 9.2 Time Class Case Study In Fig. 9.1, the class definition is enclosed in the following

More information

Programming for Engineers C Preprocessor

Programming for Engineers C Preprocessor Programming for Engineers C Preprocessor ICEN 200 Spring 2018 Prof. Dola Saha 1 C Preprocessor The C preprocessor executes before a program is compiled. Some actions it performs are the inclusion of other

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

Control flow and string example. C and C++ Functions. Function type-system nasties. 2. Functions Preprocessor. Alastair R. Beresford.

Control flow and string example. C and C++ Functions. Function type-system nasties. 2. Functions Preprocessor. Alastair R. Beresford. Control flow and string example C and C++ 2. Functions Preprocessor Alastair R. Beresford University of Cambridge Lent Term 2007 #include char s[]="university of Cambridge Computer Laboratory";

More information

COMP322 - Introduction to C++

COMP322 - Introduction to C++ COMP322 - Introduction to C++ Winter 2011 Lecture 2 - Language Basics Milena Scaccia School of Computer Science McGill University January 11, 2011 Course Web Tools Announcements, Lecture Notes, Assignments

More information

Topic 6: A Quick Intro To C

Topic 6: A Quick Intro To C Topic 6: A Quick Intro To C Assumption: All of you know Java. Much of C syntax is the same. Also: Many of you have used C or C++. Goal for this topic: you can write & run a simple C program basic functions

More information

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Data Types Basic Types Enumerated types The type void Derived types

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

C Programming Review CSC 4320/6320

C Programming Review CSC 4320/6320 C Programming Review CSC 4320/6320 Overview Introduction C program Structure Keywords & C Types Input & Output Arrays Functions Pointers Structures LinkedList Dynamic Memory Allocation Macro Compile &

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

G52CPP C++ Programming Lecture 6. Dr Jason Atkin

G52CPP C++ Programming Lecture 6. Dr Jason Atkin G52CPP C++ Programming Lecture 6 Dr Jason Atkin 1 Last lecture The Stack Lifetime of local variables Global variables Static local variables const (briefly) 2 Visibility is different from lifetime Just

More information

G52CPP C++ Programming Lecture 9

G52CPP C++ Programming Lecture 9 G52CPP C++ Programming Lecture 9 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last lecture const Constants, including pointers The C pre-processor And macros Compiling and linking And

More information

ME 461 C review Session Fall 2009 S. Keres

ME 461 C review Session Fall 2009 S. Keres ME 461 C review Session Fall 2009 S. Keres DISCLAIMER: These notes are in no way intended to be a complete reference for the C programming material you will need for the class. They are intended to help

More information

Lecture 10: building large projects, beginning C++, C++ and structs

Lecture 10: building large projects, beginning C++, C++ and structs CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 10:

More information

COMsW Introduction to Computer Programming in C

COMsW Introduction to Computer Programming in C OMsW 1003-1 Introduction to omputer Programming in Lecture 9 Spring 2011 Instructor: Michele Merler http://www1.cs.columbia.edu/~mmerler/comsw1003-1.html 1 Are omputers Smarter than Humans? Link http://latimesblogs.latimes.com/technology/2011/02/ibms-watson-on-jeopardy-computer-takes-big-leadover-humans-in-round-2.html

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 6: Recursive Functions. C Pre-processor. Cristina Nita-Rotaru Lecture 6/ Fall 2013 1 Functions: extern and static Functions can be used before they are declared static for

More information

Motivation was to facilitate development of systems software, especially OS development.

Motivation was to facilitate development of systems software, especially OS development. A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.

More information

Topic 6: A Quick Intro To C. Reading. "goto Considered Harmful" History

Topic 6: A Quick Intro To C. Reading. goto Considered Harmful History Topic 6: A Quick Intro To C Reading Assumption: All of you know basic Java. Much of C syntax is the same. Also: Some of you have used C or C++. Goal for this topic: you can write & run a simple C program

More information

QUIZ. What is wrong with this code that uses default arguments?

QUIZ. What is wrong with this code that uses default arguments? QUIZ What is wrong with this code that uses default arguments? Solution The value of the default argument should be placed in either declaration or definition, not both! QUIZ What is wrong with this code

More information

EL6483: Brief Overview of C Programming Language

EL6483: Brief Overview of C Programming Language EL6483: Brief Overview of C Programming Language EL6483 Spring 2016 EL6483 EL6483: Brief Overview of C Programming Language Spring 2016 1 / 30 Preprocessor macros, Syntax for comments Macro definitions

More information

C and C++ 2. Functions Preprocessor. Alan Mycroft

C and C++ 2. Functions Preprocessor. Alan Mycroft C and C++ 2. Functions Preprocessor Alan Mycroft University of Cambridge (heavily based on previous years notes thanks to Alastair Beresford and Andrew Moore) Michaelmas Term 2013 2014 1 / 1 Functions

More information

PESIT-BSC Department of Science & Humanities

PESIT-BSC Department of Science & Humanities LESSON PLAN 15PCD13/23 PROGRAMMING IN C AND DATA Course objectives: STRUCTURES The objective of this course is to make students to learn basic principles of Problem solving, implementing through C programming

More information

INDEX. Figure I-0. Listing I-0. Table I-0. Symbols.DIRECTIVE (see Assembler directives)? preprocessor operator 3-34

INDEX. Figure I-0. Listing I-0. Table I-0. Symbols.DIRECTIVE (see Assembler directives)? preprocessor operator 3-34 I INDEX Figure I-0. Listing I-0. Table I-0. Symbols.DIRECTIVE (see Assembler directives)? preprocessor operator 3-34 Numerics Assembler command-line switch -21 2-21 A Address alignment 2-39 Address of

More information

Motivation was to facilitate development of systems software, especially OS development.

Motivation was to facilitate development of systems software, especially OS development. A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.

More information

Ch. 3: The C in C++ - Continued -

Ch. 3: The C in C++ - Continued - Ch. 3: The C in C++ - Continued - QUIZ What are the 3 ways a reference can be passed to a C++ function? QUIZ True or false: References behave like constant pointers with automatic dereferencing. QUIZ What

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

Lecture 2: C Programming Basic

Lecture 2: C Programming Basic ECE342 Introduction to Embedded Systems Lecture 2: C Programming Basic Ying Tang Electrical and Computer Engineering Rowan University 1 Facts about C C was developed in 1972 in order to write the UNIX

More information

CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

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

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

G52CPP C++ Programming Lecture 8. Dr Jason Atkin

G52CPP C++ Programming Lecture 8. Dr Jason Atkin G52CPP C++ Programming Lecture 8 Dr Jason Atkin 1 Last lecture Dynamic memory allocation Memory re-allocation to grow arrays Linked lists Use -> rather than. pcurrent = pcurrent -> pnext; 2 Aside: do not

More information

Macros in C/C++ Computer Science and Engineering College of Engineering The Ohio State University. Lecture 33

Macros in C/C++ Computer Science and Engineering College of Engineering The Ohio State University. Lecture 33 Macros in C/C++ Computer Science and Engineering College of Engineering The Ohio State University Lecture 33 Macro Definition Directive: #define #define Example: #define BUFF_SIZE 1000 A

More information

M1-R4: Programing and Problem Solving using C (JAN 2019)

M1-R4: Programing and Problem Solving using C (JAN 2019) M1-R4: Programing and Problem Solving using C (JAN 2019) Max Marks: 100 M1-R4-07-18 DURATION: 03 Hrs 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter

More information

Tutorial 1: Introduction to C Computer Architecture and Systems Programming ( )

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

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()

More information

CSCI 123 Introduction to Programming Concepts in C++

CSCI 123 Introduction to Programming Concepts in C++ CSCI 123 Introduction to Programming Concepts in C++ Brad Rippe Brad Rippe More Classes and Dynamic Arrays Overview 11.4 Classes and Dynamic Arrays Constructors, Destructors, Copy Constructors Separation

More information

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor. 3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.

More information

Here's how you declare a function that returns a pointer to a character:

Here's how you declare a function that returns a pointer to a character: 23 of 40 3/28/2013 10:35 PM Violets are blue Roses are red C has been around, But it is new to you! ANALYSIS: Lines 32 and 33 in main() prompt the user for the desired sort order. The value entered is

More information

CSI33 Data Structures

CSI33 Data Structures Outline Department of Mathematics and Computer Science Bronx Community College October 25, 2017 Outline Outline 1 Chapter 8: A C++ Introduction For Python Programmers Function Details Assert Statements

More information

The combination of pointers, structs, and dynamic memory allocation allow for creation of data structures

The combination of pointers, structs, and dynamic memory allocation allow for creation of data structures Data Structures in C C Programming and Software Tools N.C. State Department of Computer Science Data Structures in C The combination of pointers, structs, and dynamic memory allocation allow for creation

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

QUIZ. What are 3 differences between C and C++ const variables?

QUIZ. What are 3 differences between C and C++ const variables? QUIZ What are 3 differences between C and C++ const variables? Solution QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Solution The C/C++ preprocessor substitutes mechanically,

More information

C Programming SYLLABUS COVERAGE SYLLABUS IN DETAILS

C Programming SYLLABUS COVERAGE SYLLABUS IN DETAILS C Programming C SYLLABUS COVERAGE Introduction to Programming Fundamentals in C Operators and Expressions Data types Input-Output Library Functions Control statements Function Storage class Pointer Pointer

More information

Come and join us at WebLyceum

Come and join us at WebLyceum Come and join us at WebLyceum For Past Papers, Quiz, Assignments, GDBs, Video Lectures etc Go to http://www.weblyceum.com and click Register In Case of any Problem Contact Administrators Rana Muhammad

More information

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso Why C? Test on 21 Android Devices with 32-bits and 64-bits processors and different versions

More information

Practical C Issues:! Preprocessor Directives, Multi-file Development, Makefiles. CS449 Fall 2017

Practical C Issues:! Preprocessor Directives, Multi-file Development, Makefiles. CS449 Fall 2017 Practical C Issues:! Preprocessor Directives, Multi-file Development, Makefiles CS449 Fall 2017 Multi-file Development Multi-file Development Why break code into multiple source files? Parallel development

More information

fpp: Fortran preprocessor March 9, 2009

fpp: Fortran preprocessor March 9, 2009 fpp: Fortran preprocessor March 9, 2009 1 Name fpp the Fortran language preprocessor for the NAG Fortran compiler. 2 Usage fpp [option]... [input-file [output-file]] 3 Description fpp is the preprocessor

More information

Computational Methods of Scientific Programming Fall 2007

Computational Methods of Scientific Programming Fall 2007 MIT OpenCourseWare http://ocw.mit.edu 12.010 Computational Methods of Scientific Programming Fall 2007 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

More information

COMP26120: Linked List in C (2018/19) Lucas Cordeiro

COMP26120: Linked List in C (2018/19) Lucas Cordeiro COMP26120: Linked List in C (2018/19) Lucas Cordeiro lucas.cordeiro@manchester.ac.uk Linked List Lucas Cordeiro (Formal Methods Group) lucas.cordeiro@manchester.ac.uk Office: 2.28 Office hours: 10-11 Tuesday,

More information

More on C programming

More on C programming Applied mechatronics More on C programming Sven Gestegård Robertz sven.robertz@cs.lth.se Department of Computer Science, Lund University 2017 Outline 1 Pointers and structs 2 On number representation Hexadecimal

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

Exercise Session 2 Simon Gerber

Exercise Session 2 Simon Gerber Exercise Session 2 Simon Gerber CASP 2014 Exercise 2: Binary search tree Implement and test a binary search tree in C: Implement key insert() and lookup() functions Implement as C module: bst.c, bst.h

More information

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

CODE TIME TECHNOLOGIES. Abassi RTOS MISRA-C:2004. Compliance Report

CODE TIME TECHNOLOGIES. Abassi RTOS MISRA-C:2004. Compliance Report CODE TIME TECHNOLOGIES Abassi RTOS MISRA-C:2004 Compliance Report Copyright Information This document is copyright Code Time Technologies Inc. 2012. All rights reserved. No part of this document may be

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

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

MISRA-C:2012 Standards Model Summary for C / C++

MISRA-C:2012 Standards Model Summary for C / C++ Version 9.7.1 Copyright 2017 Ltd. MISRA-C:2012 s Model Summary for C / C++ The tool suite is developed and certified to BS EN ISO 9001:2000 and SGS-TÜV Saar. This information is applicable to version 9.7.1

More information

QUIZ. Source:

QUIZ. Source: QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Ch. 4: Data Abstraction The only way to get massive increases in productivity is to leverage off other people s code. That

More information

The Waite Group's. New. Primer Plus. Second Edition. Mitchell Waite and Stephen Prata SAMS

The Waite Group's. New. Primer Plus. Second Edition. Mitchell Waite and Stephen Prata SAMS The Waite Group's New Primer Plus Second Edition Mitchell Waite and Stephen Prata SAMS PUBLISHING A Division of Prentice Hall Computer Publishing 11711 North College, Carmel, Indiana 46032 USA Contents

More information

Object-Oriented Programming

Object-Oriented Programming iuliana@cs.ubbcluj.ro Babes-Bolyai University 2018 1 / 37 Overview 1 2 3 4 5 2 / 37 Questions we will answer today What is the difference between the stack and the heap? How can we allocate and free memory

More information

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

Review of the C Programming Language

Review of the C Programming Language Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the

More information

JTSK Programming in C II C-Lab II. Lecture 1 & 2

JTSK Programming in C II C-Lab II. Lecture 1 & 2 JTSK-320112 Programming in C II C-Lab II Lecture 1 & 2 Xu (Owen) He Spring 2018 Slides modified from Dr. Kinga Lipskoch Who am I? Owen - PhD Candidate in Computer Science Contact details: Office: Research

More information

TDDE18 & 726G77. Functions

TDDE18 & 726G77. Functions TDDE18 & 726G77 Functions Labs update No more one time password. We will note who have demonstrated during the lab and register this in webreg. Use the terminal to send in your lab! Dont use Visual studio

More information

C PROGRAMMING LANGUAGE. POINTERS, ARRAYS, OPERATORS AND LOOP. CAAM 519, CHAPTER5

C PROGRAMMING LANGUAGE. POINTERS, ARRAYS, OPERATORS AND LOOP. CAAM 519, CHAPTER5 C PROGRAMMING LANGUAGE. POINTERS, ARRAYS, OPERATORS AND LOOP. CAAM 519, CHAPTER5 1. Pointers As Kernighan and Ritchie state, a pointer is a variable that contains the address of a variable. They have been

More information

Advanced Pointer & Data Storage

Advanced Pointer & Data Storage 18, 19: storage classes 14: Preprocessor & Polymorphism in C) 15 : command line building 26 : stdarg Advanced Pointer & Data Storage (for ch. 14, 15 18, 19, 26) Contents Preprocessor & Polymorphism in

More information

#include <stdio.h> int main() { printf ("hello class\n"); return 0; }

#include <stdio.h> int main() { printf (hello class\n); return 0; } C #include int main() printf ("hello class\n"); return 0; Working environment Linux, gcc We ll work with c9.io website, which works with ubuntu I recommend to install ubuntu too Also in tirgul

More information

Motor Industry Software Reliability Association (MISRA) C:2012 Standard Mapping of MISRA C:2012 items to Goanna checks

Motor Industry Software Reliability Association (MISRA) C:2012 Standard Mapping of MISRA C:2012 items to Goanna checks Goanna 3.3.2 Standards Data Sheet for MISRA C:2012 misrac2012-datasheet.pdf Motor Industry Software Reliability Association (MISRA) C:2012 Standard Mapping of MISRA C:2012 items to Goanna checks The following

More information

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++ Introduction to Programming in C++ Course Text Programming in C++, Zyante, Fall 2013 edition. Course book provided along with the course. Course Description This course introduces programming in C++ and

More information

edunepal_info

edunepal_info facebook.com/edunepal.info @ edunepal_info C interview questions (1 125) C interview questions are given with the answers in this website. We have given C interview questions faced by freshers and experienced

More information

Functions. CGS 3460, Lecture 24 Mar 6, 2006 Guest Lecturer: Jeff King

Functions. CGS 3460, Lecture 24 Mar 6, 2006 Guest Lecturer: Jeff King Functions CGS 3460, Lecture 24 Mar 6, 2006 Guest Lecturer: Jeff King Previously One-dimension array Multi-dimension array Agenda Function: Overview Define and Call Functions Function Declaration Arguments

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

Summer May 11, 2010

Summer May 11, 2010 Summer 2010 Department of Computer Science and Engineering York University Toronto May 11, 2010 1 / 40 What we did last time Overview of C to the language Program structure Types in C Operators in C IO

More information

Exercise Session 2 Systems Programming and Computer Architecture

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

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version:

SISTEMI EMBEDDED. The C Pre-processor Fixed-size integer types Bit Manipulation. Federico Baronti Last version: SISTEMI EMBEDDED The C Pre-processor Fixed-size integer types Bit Manipulation Federico Baronti Last version: 20160302 The C PreProcessor CPP (1) CPP is a program called by the compiler that processes

More information

Definition Checklist for Source Statement Counts

Definition Checklist for Source Statement Counts Definition Checklist for Source Statement Counts Definition name: Date: Originator: Measurement unit: Physical source lines Logical source statements Statement type Definition Data array When a line or

More information

C Introduction. Comparison w/ Java, Memory Model, and Pointers

C Introduction. Comparison w/ Java, Memory Model, and Pointers CS 261 Fall 2018 Mike Lam, Professor C Introduction Comparison w/ Java, Memory Model, and Pointers Please go to socrative.com on your phone or laptop, choose student login and join room LAMJMU The C Language

More information