6.s096. Introduction to C and C++
|
|
- Octavia Woods
- 7 years ago
- Views:
Transcription
1 6.s096 Introduction to C and C++ 1
2 Why? 2
3 1 You seek performance 3
4 1 You seek performance zero-overhead principle 4
5 2 You seek to interface directly with hardware 5
6 3 That s kinda it 6
7 C a nice way to avoid writing assembly language directly 7
8 C++ responds to the demands of maintaining large C projects 8
9 C++11 responds to the demands of maintaining large C++ projects 9
10 Maintain power and flexibility of what came before 10
11 Compilation Today: Pipeline 11
12 Source Code Program 12
13 main.c prog int a = gcc -o prog main.c 13
14 main.c int a = 1; prog int b = 2; gcc -o prog main.c main2.c 14
15 $ gcc -o prog main.c $./prog Hello, World! $ 15
16 $ gcc -o prog main.c $./prog Hello, World! $ 16 DONE
17 To debug the sausage, one must see how it is made. Someone, probably 17
18 Main.java int a = 1; Main.class %!(*@ java Main 18
19 Main.java int a = 1; Main.class %!(*@ java Main main.py a = 1 main.pyc %!(*@ python main.py 19
20 Main.java int a = 1; Main.class %!(*@ java Main main.py a = 1 main.pyc %!(*@ python main.py main.c main.o prog int a = 1; int a = 1; 20
21 21
22 22
23 main.c main.o prog int a = 1; int a = 1; Pre-Process Compile Link 23
24 main.c main.o prog int a = 1; int a = 1; Pre-Process main2.o %!(*@ Compile Link 24
25 Pre-Process Compile Link 25
26 Pre-Process Compile Link 26
27 #include #define #ifdef 27
28 rimshot.txt ba-dum chh joke.txt A man walks into a bar. Ouch! #include "rimshot.txt" cpp -P joke.txt 28
29 output: A man walks into a bar. Ouch! ba-dum chh cpp -P joke.txt 29
30 double.py #define fosho def #define kthx return #define wutz print These are called macros fosho double(x): kthx x * 2 wutz double(6) cpp -P double.py 30
31 output: def double(x): return x * 2 print double(6) cpp -P double.py 31
32 output: def double(x): return x * 2 print double(6) cpp -P double.py python 12 AWESOME cpp -P double.py 32
33 beer.txt #define beer(x) x bottles of \ beer on the wall... beer(99) beer(98) beer(97)... cpp -P beer.txt 33
34 beer.txt #define beer(x) x bottles of \ beer on the wall... beer(99) beer(98) beer(97)... cpp -P beer.txt 34
35 output: 99 bottles of beer on the wall bottles of beer on the wall bottles of beer on the wall cpp -P beer.txt 35
36 answer.txt What s 7 times 6? #ifdef REVEAL 42 #endif cpp -P answer.txt 36
37 output: What s 7 times 6? cpp -P answer.txt 37
38 output: What s 7 times 6???? cpp -P answer.txt 38
39 #define REVEAL cpp -P answer.txt 39
40 #define REVEAL or: cpp -P -D REVEAL answer.txt cpp -P answer.txt 40
41 output: What s 7 times 6? 42 cpp -P -D REVEAL answer.txt 41
42 answer.txt What s 7 times 6? #ifndef REVEAL 42 #endif cpp -P answer.txt 42
43 (Fancy) String Substitution 43
44 How is this used in C? 44
45 hello.c #include <stdio.h> int main() { printf("hello, World!\n"); return 0; } gcc -E hello.c 45
46 hello.c * angle brackets -> use the system search path #include <stdio.h> int main() { printf("hello, World!\n"); return 0; } gcc -E hello.c 46
47 hello.c * angle brackets -> use the system search path #include <stdio.h> int main() { printf("hello, World!\n"); return 0; } gcc -E hello.c 47
48 output: int printf(const char *,...) attribute (( format ( printf, 1, 2))); int main() { } printf("hello, World!\n"); * pretending printf is all that s defined in stdio.h gcc -E hello.c 48
49 output: int printf(const char *,...); int main() { } printf("hello, World!\n"); * pretending printf is all that s defined in stdio.h gcc -E hello.c 49
50 #include is not import pickle import java.io.*; 50
51 fib.c #define MAX_FIB 20 int fib[max_fib]; int main() { fib[0] = 0; fib[1] = 1; for(int i = 2; i < MAX_FIB; i++) fib[i] = fib[i-1] + fib[i-2]; return 0; } gcc -E fib.c 51
52 output: int fib[20]; int main() { fib[0] = 0; fib[1] = 1; for(int i = 2; i < 20; i++) fib[i] = fib[i-1] + fib[i-2]; } gcc -E fib.c 52
53 debug.c #include <stdio.h> int main() { #ifdef DEBUG printf("hello, World!\n"); #endif return 0; } gcc -DDEBUG debug.c -o debug 53
54 debug.c #include <stdio.h> int main() { printf("hello, World!\n"); return 0; } gcc -DDEBUG debug.c -o debug 54
55 debug.c #include <stdio.h> int main() { } return 0; gcc debug.c -o debug 55
56 Pre-Process Compile Link 56
57 main.c main.o prog int a = 1; int a = 1; Compile 57
58 Compile Type-checking Linear processing 58
59 Type-checking int reptile() { } return "frog"; 59
60 Type-checking int reptile() { } return "frog"; reptile.c: In function reptile : reptile.c:2:5: warning: return makes integer from pointer without a cast 60
61 Type-checking def vegetable(day): if day!= "Tuesday": return "tomato" else: return
62 Type-checking def vegetable(day): if day!= "Tuesday": return "tomato" else: return 1000 Python says: no problem 62
63 int reptile() { } return "frog"; 63
64 int () { } return char*; 64
65 int vegetable(char *day) { if (strcmp(day, "Tuesday")!= 0){ return "tomato"; } else { return 1000; } } 65
66 int (char*) { if (int){ return char*; } else { return int; } } 66
67 int (char*) { if (int){ return char*; } else { return int; } } 67
68 int (char*) { if (int){ return char*; } else { return int; } } 68
69 Everything has a single, fixed type 69
70 def foo(a, b): return a + b foo(2, 3) foo("2", "3") 70
71 Variable Declarations int foo; float foo; double foo; char foo; int foo[42]; int *foo; struct Bar foo; 71
72 Function Declarations double fmin(double, double); return type argument types 72
73 Function Declarations void exit(int); returns nothing int rand(void); takes no arguments 73
74 int foo(int a, int b){ } return a + b; 74
75 reptile.c: In function reptile : reptile.c:2:5: warning: return makes integer from pointer without a cast 75
76 reptile.c: In function reptile : reptile.c:2:5: warning: return makes integer from pointer without a cast int a = 4; float b = (float)a; 76
77 all theoretical casts int float double char int[] int* void (*f )(int) struct X int float double char int[] int* void (*f )(int) struct X 77
78 allowed casts int float double char int[] int* void (*f )(int) struct X int float double char int[] int* void (*f )(int) struct X 78
79 79
80 allowed casts int float double char int[] int* void (*f )(int) struct X int float double char int[] int* void (*f )(int) struct X 80
81 allowed casts int float double char int[] int* void (*f )(int) struct X int float double char int[] int* void (*f )(int) struct X 81
82 implicit casts int float double char int[] int* void (*f )(int) struct X int float double char int[] int* void (*f )(int) struct X 82
83 implicit casts int float double char int[] int* void (*f )(int) struct X int float double char int[] int* void (*f )(int) struct X 83
84 implicit casts int float double char int[] int* void (*f )(int) struct X int float double char int[] int* void (*f )(int) struct X 84
85 implicit casts int float double char int[] int* void (*f )(int) struct X int float double char int[] int* void (*f )(int) struct X 85
86 Compile Type-checking Linear processing 86
87 Linear processing ( just a small note) 87
88 You can only use what s declared above 88
89 int main() { printf("%d\n", answer()); return 0; } int answer() { } return 1337; 89
90 int main() { printf("%d\n", answer()); return 0; } int answer() { } return 1337; 90
91 int answer() { } return 1337; int main() { printf("%d\n", answer()); return 0; } 91
92 int answer(); declaration int main() { printf("%d\n", answer()); return 0; } int answer() { definition return 1337; } 92
93 HMM 93
94 int answer(); declaration int main() { printf("%d\n", answer()); return 0; } int answer() { definition return 1337; } 94
95 int answer(); declaration int main() { printf("%d\n", answer()); return 0; } int answer() { definition return 1337; } 95
96 int answer(); declaration #include "answer.h" int main() { printf("%d\n", answer()); return 0; } int answer() { definition return 1337; } 96
97 Pre-Process Compile Link 97
98 main.o int main() int answer() 98
99 main.o int main() 99
100 answer.c: In function main : answer.c:4: warning: implicit declaration of function answer Undefined symbols for architecture x86_64: "_answer", referenced from: _main in ccuzmrrm.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status 100
101 answer.c: In function main : answer.c:4: warning: implicit declaration of function answer Undefined symbols for architecture x86_64: "_answer", referenced from: _main in ccuzmrrm.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status 101
102 answer.c: In function main : answer.c:4: warning: implicit declaration of function answer Undefined symbols for architecture x86_64: "_answer", referenced from: _main in ccuzmrrm.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status Compiler: I don t know what answer is. I ll assume it returns an int. 102
103 answer.c: In function main : answer.c:4: warning: implicit declaration of function answer Undefined symbols for architecture x86_64: "_answer", referenced from: _main in ccuzmrrm.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status 103
104 answer.c: In function main : answer.c:4: warning: implicit declaration of function answer Undefined symbols for architecture x86_64: "_answer", referenced from: _main in ccuzmrrm.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status Linker: I looked in all the object files, but I couldn t find answer. 104
105 main.o int main() 105
106 main.o answer.o int main() int answer() 106
107 main.o answer.o int main() int answer() int main() { printf("%d\n", answer()); return 0; } int answer() { return 1337; } 107
108 main.o answer.o int main() int answer() 108
109 prog int main() int answer() gcc -o prog main.c answer.c 109
110 answer.c: In function main : answer.c:4: warning: implicit declaration of function answer 110
111 answer.c: In function main : answer.c:4: warning: implicit declaration of function answer Compiler: I don t know what answer is. I ll assume it returns an int. 111
112 answer.h int answer(); main.c #include "answer.h" int main() { printf("%d\n", answer()); return 0; } 112
113 answer.h int answer(); answer.c #include "answer.h" int answer() { } return 1337; 113
114 Summary 114
115 answer.h int answer(); main.c #include "answer.h" int main() { printf("%d\n", answer()); return 0; } 115
116 Preprocess: gcc -E main.c int answer(); int main() { printf("%d\n", answer()); return 0; } 116
117 Compile: gcc -c main.c main.c main.o answer.o 117
118 Link: gcc -o prog main.o main.o prog 118
119 Pre-Process Compile Link 119
120 MIT OpenCourseWare 6.S096 Introduction to C and C++ IAP 2013 For information about citing these materials or our Terms of Use, visit:
6.S096 Lecture 1 Introduction to C
6.S096 Lecture 1 Introduction to C Welcome to the Memory Jungle Andre Kessler Andre Kessler 6.S096 Lecture 1 Introduction to C 1 / 30 Outline 1 Motivation 2 Class Logistics 3 Memory Model 4 Compiling 5
More informationChapter 13 - The Preprocessor
Chapter 13 - The Preprocessor Outline 13.1 Introduction 13.2 The#include Preprocessor Directive 13.3 The#define Preprocessor Directive: Symbolic Constants 13.4 The#define Preprocessor Directive: Macros
More informationLecture 27 C and Assembly
Ananda Gunawardena Lecture 27 C and Assembly This is a quick introduction to working with x86 assembly. Some of the instructions and register names must be check for latest commands and register names.
More information1 Abstract Data Types Information Hiding
1 1 Abstract Data Types Information Hiding 1.1 Data Types Data types are an integral part of every programming language. ANSI-C has int, double and char to name just a few. Programmers are rarely content
More informationHow To Use The C Preprocessor
Environnements et Outils de Développement Cours 3 The C build process Stefano Zacchiroli zack@pps.univ-paris-diderot.fr Laboratoire PPS, Université Paris Diderot - Paris 7 URL http://upsilon.cc/~zack/teaching/1112/ed6/
More informationSources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
More informationHow To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)
TN203 Porting a Program to Dynamic C Introduction Dynamic C has a number of improvements and differences compared to many other C compiler systems. This application note gives instructions and suggestions
More informationThe programming language C. sws1 1
The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan
More informationEmbedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
More informationThe C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
More informationInformatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
More informationApplied Programming and Computer Science, DD2325/appcs15 PODF, Programmering och datalogi för fysiker, DA7011
Applied Programming and Computer Science, DD2325/appcs5 PODF, Programmering och datalogi för fysiker, DA7 Autumn 25 Lecture 6, Huffman coding and hashing A. Maki, C. Edlund Tree When are trees used? Binary
More informationSemantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
More informationHow To Write Portable Programs In C
Writing Portable Programs COS 217 1 Goals of Today s Class Writing portable programs in C Sources of heterogeneity Data types, evaluation order, byte order, char set, Reading period and final exam Important
More informationFirst Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
More informationCP Lab 2: Writing programs for simple arithmetic problems
Computer Programming (CP) Lab 2, 2015/16 1 CP Lab 2: Writing programs for simple arithmetic problems Instructions The purpose of this Lab is to guide you through a series of simple programming problems,
More informationFundamentals of Programming
Fundamentals of Programming Introduction to the C language Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) The C language
More informationSection 6 Spring 2013
Print Your Name You may use one page of hand written notes (both sides) and a dictionary. No i-phones, calculators or any other type of non-organic computer. Do not take this exam if you are sick. Once
More informationParameter Passing. Standard mechanisms. Call by value-result Call by name, result
Parameter Passing Standard mechanisms Call by value Call by reference Other methods Call by value-result Call by name, result Terms Function definition where the details of the function are presented (type,
More informationarrays C Programming Language - Arrays
arrays So far, we have been using only scalar variables scalar meaning a variable with a single value But many things require a set of related values coordinates or vectors require 3 (or 2, or 4, or more)
More informationHow to Write a Simple Makefile
Chapter 1 CHAPTER 1 How to Write a Simple Makefile The mechanics of programming usually follow a fairly simple routine of editing source files, compiling the source into an executable form, and debugging
More informationStatic vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer
Lecture 10: Static Semantics Overview 1 Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces trees Detects & eliminates ill-formed parse trees Static semantic analysis
More informationIntroduction to Python
Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment
More informationObject-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007
Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,
More informationPhys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions
Phys4051: C Lecture 2 & 3 Functions (Review) Comment Statements Variables & Operators Branching Instructions Comment Statements! Method 1: /* */! Method 2: // /* Single Line */ //Single Line /* This comment
More informationC++FA 5.1 PRACTICE MID-TERM EXAM
C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer
More informationCOMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms.
COMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms 1 Activation Records activation declaration location Recall that an activation
More informationC / C++ and Unix Programming. Materials adapted from Dan Hood and Dianna Xu
C / C++ and Unix Programming Materials adapted from Dan Hood and Dianna Xu 1 C and Unix Programming Today s goals ú History of C ú Basic types ú printf ú Arithmetic operations, types and casting ú Intro
More informationStorage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas
CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage
More informationIS0020 Program Design and Software Tools Midterm, Feb 24, 2004. Instruction
IS0020 Program Design and Software Tools Midterm, Feb 24, 2004 Name: Instruction There are two parts in this test. The first part contains 50 questions worth 80 points. The second part constitutes 20 points
More informationLecture 22: C Programming 4 Embedded Systems
Lecture 22: C Programming 4 Embedded Systems Today s Goals Basic C programming process Variables and constants in C Pointers to access addresses Using a High Level Language High-level languages More human
More informationAn Incomplete C++ Primer. University of Wyoming MA 5310
An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages
More informationNext, the driver runs the C compiler (cc1), which translates main.i into an ASCII assembly language file main.s.
Chapter 7 Linking Linking is the process of collecting and combining various pieces of code and data into a single file that can be loaded (copied) into memory and executed. Linking can be performed at
More informationIntroduction to Data Structures
Introduction to Data Structures Albert Gural October 28, 2011 1 Introduction When trying to convert from an algorithm to the actual code, one important aspect to consider is how to store and manipulate
More informationKeil C51 Cross Compiler
Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation
More informationParallel Computing. Parallel shared memory computing with OpenMP
Parallel Computing Parallel shared memory computing with OpenMP Thorsten Grahs, 14.07.2014 Table of contents Introduction Directives Scope of data Synchronization OpenMP vs. MPI OpenMP & MPI 14.07.2014
More informationGetting Started with 1. Borland C++Builder Compiler
Getting Started with 1 Borland C++Builder Compiler Objectives To be able to install and configure the Borland C++Builder Compiler. To be able to use a text editor to create C/C++ programs. To be able to
More informationIntroduction to MS Visual Studio 6.0
2/24/2003 Burkhard Wünsche Introduction to MS Visual C/C++ 6.0 Page 1 of 9 0. Introduction: Introduction to MS Visual Studio 6.0 Part 1 of this tutorial gives a simple introduction to MS Visual Studio
More informationA deeper look at Inline functions
A deeper look at Inline functions I think it s safe to say that all Overload readers know what C++ inline functions are. When we declare a function or member function as inline we are trying to avoid the
More informationAn Introduction to Assembly Programming with the ARM 32-bit Processor Family
An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2
More informationASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters
The char Type ASCII Encoding The C char type stores small integers. It is usually 8 bits. char variables guaranteed to be able to hold integers 0.. +127. char variables mostly used to store characters
More informationlanguage 1 (source) compiler language 2 (target) Figure 1: Compiling a program
CS 2112 Lecture 27 Interpreters, compilers, and the Java Virtual Machine 1 May 2012 Lecturer: Andrew Myers 1 Interpreters vs. compilers There are two strategies for obtaining runnable code from a program
More informationBachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)
Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating
More informationCSC230 Getting Starting in C. Tyler Bletsch
CSC230 Getting Starting in C Tyler Bletsch What is C? The language of UNIX Procedural language (no classes) Low-level access to memory Easy to map to machine language Not much run-time stuff needed Surprisingly
More informationPRI-(BASIC2) Preliminary Reference Information Mod date 3. Jun. 2015
PRI-(BASIC2) Table of content Introduction...2 New Comment...2 Long variable...2 Function definition...3 Function declaration...3 Function return value...3 Keyword return inside functions...4 Function
More informationIntroduction to Java
Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high
More informationParallel Computing. Shared memory parallel programming with OpenMP
Parallel Computing Shared memory parallel programming with OpenMP Thorsten Grahs, 27.04.2015 Table of contents Introduction Directives Scope of data Synchronization 27.04.2015 Thorsten Grahs Parallel Computing
More informationComp151. Definitions & Declarations
Comp151 Definitions & Declarations Example: Definition /* reverse_printcpp */ #include #include using namespace std; int global_var = 23; // global variable definition void reverse_print(const
More informationComputer Programming Tutorial
Computer Programming Tutorial COMPUTER PROGRAMMING TUTORIAL by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Computer Prgramming Tutorial Computer programming is the act of writing computer
More informationPROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms
PROG0101 FUNDAMENTALS OF PROGRAMMING Chapter 3 1 Introduction to A sequence of instructions. A procedure or formula for solving a problem. It was created mathematician, Mohammed ibn-musa al-khwarizmi.
More informationMoving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
More informationsys socketcall: Network systems calls on Linux
sys socketcall: Network systems calls on Linux Daniel Noé April 9, 2008 The method used by Linux for system calls is explored in detail in Understanding the Linux Kernel. However, the book does not adequately
More informationpublic static void main(string[] args) { System.out.println("hello, world"); } }
Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static
More informationCOMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing
COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing The scanner (or lexical analyzer) of a compiler processes the source program, recognizing
More informationLink time dead code and data elimination using GNU toolchain. Denys Vlasenko
Link time dead code and data elimination using GNU toolchain Denys Vlasenko It makes sense to run the same software on embedded devices as we run on desktops (for example, Linux kernel), in order to leverage
More informationSimple C Programs. Goals for this Lecture. Help you learn about:
Simple C Programs 1 Goals for this Lecture Help you learn about: Simple C programs Program structure Defining symbolic constants Detecting and reporting failure Functionality of the gcc command Preprocessor,
More informationELEC3730 Embedded Systems Lecture 1: Introduction and C Essentials
ELEC3730 Embedded Systems Lecture 1: Introduction and C Essentials Overview of Embedded Systems Essentials of C programming - Lecture 1 1 Embedded System Definition and Examples Embedded System Definition:
More informationAdvanced Bash Scripting. Joshua Malone (jmalone@ubergeeks.com)
Advanced Bash Scripting Joshua Malone (jmalone@ubergeeks.com) Why script in bash? You re probably already using it Great at managing external programs Powerful scripting language Portable and version-stable
More informationArrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.
Arrays Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html 1 Grid in Assignment 2 How do you represent the state
More informationCS 241 Data Organization Coding Standards
CS 241 Data Organization Coding Standards Brooke Chenoweth University of New Mexico Spring 2016 CS-241 Coding Standards All projects and labs must follow the great and hallowed CS-241 coding standards.
More informationGetting Started with the Internet Communications Engine
Getting Started with the Internet Communications Engine David Vriezen April 7, 2014 Contents 1 Introduction 2 2 About Ice 2 2.1 Proxies................................. 2 3 Setting Up ICE 2 4 Slices 2
More informationMemory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example
Announcements Memory management Assignment 2 posted, due Friday Do two of the three problems Assignment 1 graded see grades on CMS Lecture 7 CS 113 Spring 2008 2 Safe user input If you use scanf(), include
More informationJ a v a Quiz (Unit 3, Test 0 Practice)
Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points
More informationINTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011
INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 1 Goals of the Lecture Present an introduction to Objective-C 2.0 Coverage of the language will be INCOMPLETE
More informationC++ INTERVIEW QUESTIONS
C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get
More informationLecture 5: Java Fundamentals III
Lecture 5: Java Fundamentals III School of Science and Technology The University of New England Trimester 2 2015 Lecture 5: Java Fundamentals III - Operators Reading: Finish reading Chapter 2 of the 2nd
More informationUsing Visual C++ and Pelles C
Using Visual C++ and Pelles C -IDE & Compilerswww.tenouk.com, 1/48 (2008) In this session we will learn how to use VC++ to build a sample C program. We assume VC++ (Visual Studio) was successfully installed.
More informationMolecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct
Dr. Martin O. Steinhauser University of Basel Graduate Lecture Spring Semester 2014 Molecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct Friday, 7 th March
More informationBeyond the Mouse A Short Course on Programming
1 / 22 Beyond the Mouse A Short Course on Programming 2. Fundamental Programming Principles I: Variables and Data Types Ronni Grapenthin Geophysical Institute, University of Alaska Fairbanks September
More informationcsce4313 Programming Languages Scanner (pass/fail)
csce4313 Programming Languages Scanner (pass/fail) John C. Lusth Revision Date: January 18, 2005 This is your first pass/fail assignment. You may develop your code using any procedural language, but you
More informationCS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)
More informationReal SQL Programming. Persistent Stored Modules (PSM) PL/SQL Embedded SQL
Real SQL Programming Persistent Stored Modules (PSM) PL/SQL Embedded SQL 1 SQL in Real Programs We have seen only how SQL is used at the generic query interface --- an environment where we sit at a terminal
More informationMPLAB TM C30 Managed PSV Pointers. Beta support included with MPLAB C30 V3.00
MPLAB TM C30 Managed PSV Pointers Beta support included with MPLAB C30 V3.00 Contents 1 Overview 2 1.1 Why Beta?.............................. 2 1.2 Other Sources of Reference..................... 2 2
More informationThe Function Pointer
The Function Pointer 1. Introduction to Function Pointers Function Pointers provide some extremely interesting, efficient and elegant programming techniques. You can use them to replace switch/if-statements,
More informationNumber Representation
Number Representation CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Topics to be Discussed How are numeric data
More informationCS 294-73 Software Engineering for Scientific Computing. http://www.cs.berkeley.edu/~colella/cs294. Lecture 25:Mixed Language Programming.
CS 294-73 Software Engineering for Scientific Computing http://www.cs.berkeley.edu/~colella/cs294 Lecture 25:Mixed Language Programming. Different languages Technical, historical, cultural differences
More informationSystems Programming & Scripting
Systems Programming & Scripting Lecture 14 - Shell Scripting: Control Structures, Functions Syst Prog & Scripting - Heriot Watt University 1 Control Structures Shell scripting supports creating more complex
More informationCOS 217: Introduction to Programming Systems
COS 217: Introduction to Programming Systems 1 Goals for Todayʼs Class Course overview Introductions Course goals Resources Grading Policies Getting started with C C programming language overview 2 1 Introductions
More informationExample of a Java program
Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);
More informationTODAY, FEW PROGRAMMERS USE ASSEMBLY LANGUAGE. Higher-level languages such
9 Inline Assembly Code TODAY, FEW PROGRAMMERS USE ASSEMBLY LANGUAGE. Higher-level languages such as C and C++ run on nearly all architectures and yield higher productivity when writing and maintaining
More informationIntroClassJava: A Benchmark of 297 Small and Buggy Java Programs
IntroClassJava: A Benchmark of 297 Small and Buggy Java Programs Thomas Durieux, Martin Monperrus To cite this version: Thomas Durieux, Martin Monperrus. IntroClassJava: A Benchmark of 297 Small and Buggy
More informationHandout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
More informationKeywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void
1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of
More informationIntro to Intel Galileo - IoT Apps GERARDO CARMONA
Intro to Intel Galileo - IoT Apps GERARDO CARMONA IRVING LLAMAS Welcome! Campus Party Guadalajara 2015 Introduction In this course we will focus on how to get started with the Intel Galileo Gen 2 development
More informationPostgreSQL Functions By Example
Postgre joe.conway@credativ.com credativ Group January 20, 2012 What are Functions? Introduction Uses Varieties Languages Full fledged SQL objects Many other database objects are implemented with them
More informationObject Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
More information#pragma omp critical x = x + 1; !$OMP CRITICAL X = X + 1!$OMP END CRITICAL. (Very inefficiant) example using critical instead of reduction:
omp critical The code inside a CRITICAL region is executed by only one thread at a time. The order is not specified. This means that if a thread is currently executing inside a CRITICAL region and another
More informationSoftware documentation systems
Software documentation systems Basic introduction to various user-oriented and developer-oriented software documentation systems. Ondrej Holotnak Ondrej Jombik Software documentation systems: Basic introduction
More informationDebugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go
Debugging ESE112 Java Programming: API, Psuedo-Code, Scope It is highly unlikely that you will write code that will work on the first go Bugs or errors Syntax Fixable if you learn to read compiler error
More informationMasters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013
Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper
More informationEmbedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C
Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C 1 An essential part of any embedded system design Programming 2 Programming in Assembly or HLL Processor and memory-sensitive
More informationIn this Chapter you ll learn:
Now go, write it before them in a table, and note it in a book. Isaiah 30:8 To go beyond is as wrong as to fall short. Confucius Begin at the beginning, and go on till you come to the end: then stop. Lewis
More informationIllustration 1: Diagram of program function and data flow
The contract called for creation of a random access database of plumbing shops within the near perimeter of FIU Engineering school. The database features a rating number from 1-10 to offer a guideline
More informationCpSc212 Goddard Notes Chapter 6. Yet More on Classes. We discuss the problems of comparing, copying, passing, outputting, and destructing
CpSc212 Goddard Notes Chapter 6 Yet More on Classes We discuss the problems of comparing, copying, passing, outputting, and destructing objects. 6.1 Object Storage, Allocation and Destructors Some objects
More informationParallel and Distributed Computing Programming Assignment 1
Parallel and Distributed Computing Programming Assignment 1 Due Monday, February 7 For programming assignment 1, you should write two C programs. One should provide an estimate of the performance of ping-pong
More informationTutorial on C Language Programming
Tutorial on C Language Programming Teodor Rus rus@cs.uiowa.edu The University of Iowa, Department of Computer Science Introduction to System Software p.1/64 Tutorial on C programming C program structure:
More informationRemoving False Code Dependencies to Speedup Software Build Processes
Removing False Code Dependencies to Speedup Software Build Processes Yijun Yu Homy Dayani-Fard John Mylopoulos yijun@cs.toronto.edu homy@cs.toronto.edu jm@cs.toronto.edu University of Toronto IBM Canada
More information8.5. <summary>...26 9. Cppcheck addons...27 9.1. Using Cppcheck addons...27 9.1.1. Where to find some Cppcheck addons...27 9.2.
Cppcheck 1.72 Cppcheck 1.72 Table of Contents 1. Introduction...1 2. Getting started...2 2.1. First test...2 2.2. Checking all files in a folder...2 2.3. Excluding a file or folder from checking...2 2.4.
More informationLecture 2 Notes: Flow of Control
6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The
More informationJava Basics: Data Types, Variables, and Loops
Java Basics: Data Types, Variables, and Loops If debugging is the process of removing software bugs, then programming must be the process of putting them in. - Edsger Dijkstra Plan for the Day Variables
More information