Discussion 6. HW4 and Libraries

Similar documents
SWEN-250 Personal SE. Introduction to C

(T) x. Casts. A cast converts the value held in variable x to type T

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions

Lecture 9 Assertions and Error Handling CS240

Cache and Virtual Memory Simulations

CSE 333 Midterm Exam 5/9/14 Sample Solution

Flow Control. CSC215 Lecture

CS261: HOMEWORK 2 Due 04/13/2012, at 2pm

Link 7.A Static Linking

System calls. Reading from a file. Closing a file

Linked-List Basic Examples. A linked-list is Linear collection of self-referential class objects, called nodes Connected by pointer links

Standard File Pointers

Writing Functions in C

CSE 333 Midterm Exam July 24, 2017 Sample Solution

CS201 Some Important Definitions

CSE 333 Midterm Exam Nov. 3, 2017 Sample Solution

CS 2301 Exam 3 B-Term 2011

This exam is worth 24 points, or 24% of your total course grade. The exam contains six

CS 251 Practice Final Exam R. Brown May 1, 2015 SHOW YOUR WORK No work may mean no credit Point totals will be adjusted to a 120 point scale later

QUIZ. Can you find 5 errors in this code?

APSIN x000 API Description

Classes: Member functions // classes example #include <iostream> using namespace std; Objects : Reminder. Member functions: Methods.

CS201- Introduction to Programming Current Quizzes

Objectives. External declarations Pointers Dynamic data structures using pointers Function pointers

Data compression.

However, in C we can group related variables together into something called a struct.

CS 110 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger.

Fundamentals of Programming. Lecture 11: C Characters and Strings

CSE 431S Type Checking. Washington University Spring 2013

This Document describes the API provided by the DVB-Multicast-Client library

1 SAT-DANCE-HEULE INTRO 1

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #54. Organizing Code in multiple files

CSE 333 Midterm Exam 7/27/15 Sample Solution

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #10

C Syntax Out: 15 September, 1995

Static Vulnerability Analysis

Write a program that creates in the main function two linked lists of characters and fills them with the following values:

The output will be: marks all or nothing. 1 #include <stdio.h> 2 main() { 3 int i; int j; 4 int *p; int *q; 6 p = &i; 7 q = &j; 8 i = 1;

Next week s homework. Classes: Member functions. Member functions: Methods. Objects : Reminder. Objects : Reminder 3/6/2017

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 2. Spring 2016

Aria VMX Emulation Framework

CS 61C: Great Ideas in Computer Architecture Introduction to C

University of Massachusetts - Boston Programming in C CS Spring 2018

Section - Computer Science. int main() {! int a=10,b=20;! printf("a:%d B:%d\n",a,b);! a=(a+b)-(b=a);! printf("a:%d B:%d\n",a,b);!

EE475 Lab #3 Fall Memory Placement and Interrupts

Approximately a Final Exam CPSC 206

libsegy Programmer s Reference Manual

CSE 333 Midterm Exam July 24, Name UW ID#

Computer Science II CSci 1200 Sections 1-4,6 Week 6, Friday Class October 5, 2001 Linked Lists, Part 2

CS241 Computer Organization Spring Data Alignment

Slide Set 5. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Lesson 8: Linked List Deque

CSci 4061 Introduction to Operating Systems. Input/Output: High-level

Machine Language, Assemblers and Linkers"

CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11

Comp Sci 1MD3 Mid-Term II 2003 answers

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

Computer Programming

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #33 Pointer Arithmetic

Stack. 4. In Stack all Operations such as Insertion and Deletion are permitted at only one end. Size of the Stack 6. Maximum Value of Stack Top 5

CIS 190: C/C++ Programming. Lecture 2 Pointers and More

Static Program Analysis Part 1 the TIP language

FOR Loop. FOR Loop has three parts:initialization,condition,increment. Syntax. for(initialization;condition;increment){ body;

ECE264 Spring 2013 Final Exam, April 30, 2013

1. port 2: 'a' 3. port 2: '\n' 5. port 1: 'y' 2. port 1: 'x' 4. port 2: 'b' 6. port 1: '\n'

EL2310 Scientific Programming

Exam Principles of Imperative Computation, Summer 2011 William Lovas. June 24, 2011

CS 1713 Introduction to Programming II

Student Number: Instructor: Reid Section: L5101 (6:10-7:00pm)

Programming refresher and intro to C programming

CSE 374 Final Exam Sample Solution 3/15/12

CS-211 Fall 2017 Test 2 Version A November 29, Name:

SOFTWARE Ph.D. Qualifying Exam Spring Consider the following C program, which includes three function definitions, including the main function.

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

Lecture 16 CSE July 1992

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

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

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

libnetfilter_log Reference Manual

Input/Output Week 5:Lesson 16.1

Hash Table and Hashing

Reg. No. : Question Paper Code : 27157

Introduction to C. Sami Ilvonen Petri Nikunen. Oct 6 8, CSC IT Center for Science Ltd, Espoo. int **b1, **b2;

today cs3157-fall2002-sklar-lect05 1

CS 0449 Sample Midterm

Midterm Exam Nov 8th, COMS W3157 Advanced Programming Columbia University Fall Instructor: Jae Woo Lee.

Pebbles Kernel Specification September 26, 2004

CIS 2107 Computer Systems and Low-Level Programming Fall 2011 Midterm Solutions

Differentiability and Tangent Planes October 2013

PROGRAMMAZIONE I A.A. 2017/2018

File Access. FILE * fopen(const char *name, const char * mode);

Linked List Practice Questions

Homework 4 Answers. Due Date: Monday, May 27, 2002, at 11:59PM Points: 100. /* * macros */ #define SZBUFFER 1024 /* max length of input buffer */

ch = argv[i][++j]; /* why does ++j but j++ does not? */

Mid-term Exam. Fall Semester 2017 KAIST EE209 Programming Structures for Electrical Engineering. Name: Student ID:

C++ ARRAYS POINTERS POINTER ARITHMETIC. Problem Solving with Computers-I

Lab # 4. Files & Queues in C

ECE 264 Exam 2. 6:30-7:30PM, March 9, You must sign here. Otherwise you will receive a 1-point penalty.

A brief introduction to C programming for Java programmers

CS 33. Introduction to C. Part 5. CS33 Intro to Computer Systems V 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

Transcription:

Discussion 6 HW4 and Libraries

Let s talk Assignment 4 Builds on Assignment 3 concepts

Let s talk Assignment 4 Builds on Assignment 3 concepts Now, you have to build a glossary.

Pointer to pointer int** x; int* y = (int*)malloc(sizeof int); x=&y;

Explanation of search() struct WordSet { int size; *head;

Explanation of search() struct { int freq; char *word; ; struct WordSet { int size; *head;

Explanation of search() Start 2 by 3 possible 1 NULL *head p WordSet struct { int freq; char *word; ; struct WordSet { int size; *head;

Explanation of search() Start 2 by 3 possible 1 NULL p *head WordSet struct { int freq; char *word; ; struct WordSet { int size; *head;

Explanation of search() Start 2 by 3 possible 1 NULL p *head WordSet struct { int freq; char *word; ; struct WordSet { int size; *head;

Explanation of search() Start 2 by 3 possible 1 NULL p *head WordSet struct { int freq; char *word; ; struct WordSet { int size; *head;

Explanation of search() Start 2 by 3 possible 1 NULL p *head WordSet struct { int freq; char *word; ; struct WordSet { int size; *head;

i-clicker question Suppose p points to a pointer to a, how do we access the s word? A. p->word B. (*p)->word C. (**p)->word struct { int freq; char *word; ;

i-clicker question Suppose p points to a pointer to a, how do we access the word of the s immediate successor? A. (*((*p)->next)).word B. ((*p)->next).word C. ((*p)->next)->word D. (*((*p)->next))->word struct { int freq; char *word; ;

Return value of search static **search (WordSet *wset, char *word) { found a matching wordnode

Return value of search static **search (WordSet *wset, char *word) { found a matching wordnode Reached the end of linked list

Return value of search static **search (WordSet *wset, char *word) { found a matching wordnode Reached the end of linked list

Return value of search static **search (WordSet *wset, char *word) { found a matching wordnode Reached the end of linked list Can be used for adding and removing a Add: let *return points to the newly created node if a maching wordnode is not found

Return value of search static **search (WordSet *wset, char *word) { found a matching wordnode Reached the end of linked list Can be used for adding and removing a Add: let *return points to the newly created node if a maching wordnode is not found Remove: let *return points to the next node of the given word node s immediate successor if a matching wordnode is found

Return value of search static **search (WordSet *wset, char *word) { found a matching wordnode Reached the end of linked list Can be used for adding and removing a Add: let *return points to the newly created node if a maching wordnode is not found Remove: let *return points to the next node of the given word node s immediate successor if a matching wordnode is found Fast Add: first remove, then add at the beginning

Two loops words_next_word

words_next_word Two loops Skip over leading non-alphanumeric characters Isalnum: <ctype.h>

words_next_word Two loops Skip over leading non-alphanumeric characters Isalnum: <ctype.h> Store all alphanumeric characters into buf before calling make_string Do I call make_string with an empty buffer? Do I need to null-terminate in buf?

words_next_word Two loops Skip over leading non-alphanumeric characters Isalnum: <ctype.h> Store all alphanumeric characters into buf before calling make_string Do I call make_string with an empty buffer? Do I need to null-terminate in buf? Use getchar() to read more characters

words_next_word Two loops Skip over leading non-alphanumeric characters Isalnum: <ctype.h> Store all alphanumeric characters into buf before calling make_string Do I call make_string with an empty buffer? Do I need to null-terminate in buf? Use getchar() to read more characters Hand simulate the function on various cases

Wset_free Free nodes in the linked list Free the word set

Group Activity What is linking? What is the purpose of linking? Could you compare static linking and dynamic linking? Suppose foo.c calls functions in libx.a; libx.a calls functions in liby.a; liby.a calls functions in libx.a; libx.a calls functions in foo.c. What is the gcc command line that will allow the static linker to resolve all symbol references? What is the difference between a definition and a declaration? When do we use extern?