STRINGS. If you follow the rule of array initialization then you can write the above statement as follows:

Size: px
Start display at page:

Download "STRINGS. If you follow the rule of array initialization then you can write the above statement as follows:"

Transcription

1 STRINGS The string in C programming language is actually a one-dimensional array of characters which is terminated by a null character '\0'. Thus a null-terminated string contains the characters that comprise the string followed by a null. The following declaration and initialization create a string consisting of the word "Hello". To hold the null character at the end of the array, the size of the character array containing the string is one more than the number of characters in the word "Hello." char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'; If you follow the rule of array initialization then you can write the above statement as follows: char greeting[] = "Hello"; Following is the memory presentation of above defined string in C/C++: Actually, you do not place the null character at the end of a string constant. The C compiler automatically places the '\0' at the end of the string when it initializes the array. Let us try to print above mentioned string: #include <stdio.h> int main () { char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'; printf("greeting message: %s\n", greeting ); return 0; When the above code is compiled and executed, it produces result something as follows: Greeting message: Hello

2 C supports a wide range of functions that manipulate null-terminated strings: S.N Function & Purpose strcpy(s1, s2); Copies string s2 into string s1. strcat(s1, s2); Concatenates string s2 onto the end of string s1. strlen(s1); Returns the length of string s1. strcmp(s1, s2); Returns 0 if s1 and s2 are the same; less than 0 if s1<s2; greater than 0 if s1>s2. strchr(s1, ch); Returns a pointer to the first occurrence of character ch in string s1. strstr(s1, s2); Returns a pointer to the first occurrence of string s2 in string s1. Following example makes use of few of the above-mentioned functions: #include <stdio.h> #include <string.h> int main () { char str1[12] = "Hello"; char str2[12] = "World"; char str3[12]; int len ; /* copy str1 into str3 strcpy(str3, str1); printf("strcpy( str3, str1) : %s\n", str3 ); /* concatenates str1 and str2 strcat( str1, str2); printf("strcat( str1, str2): %s\n", str1 ); /* total lenghth of str1 after concatenation len = strlen(str1); printf("strlen(str1) : %d\n", len ); return 0; When the above code is compiled and executed, it produces result something as follows: strcpy( str3, str1) : Hello strcat( str1, str2): HelloWorld strlen(str1) : 10

3 STRINGS in C string: array of characters terminated by NULL character string in/output: printf("%s",s), scanf("%s",s) string.h : collection of functions for string manipulation no standard operators for string assignment and comparisons! (remember: strings are arrays!) Arrays of Characters /* strings are array of characters * terminated by the NULL character * which is different from '0' char S[MAX_STRING_LEN]; int l, i; S[0] = 'a'; S[1] = 'b'; S[2] = 'c'; S[3] = 'd'; S[4] = 'e'; S[5] = 'g'; S[6] = '0'; S[7] = 0; l = strlen(s); printf("s:\t%s\n",s); printf("length:\t%d\n",l); /* print characters in S printf("forward\n"); for (i = 0; i < l; ++i) printf("a[%d] = %c\n",i,s[i]); /* print characters in S backwards printf("\nbackward\n"); for (i = l-1; i >= 0; --i)

4 printf("a[%d] = %c\n",i,s[i]); String IO /* strings can be read using scanf with %s * string.h contains many useful functions * for working with strings: * strcmp for string comparisons * strcpy to copy strings *... * * Check what happens if your input contains * spaces, tabs, etc * char S1[MAX_STRING_LEN]; char S2[MAX_STRING_LEN]; int i, l; printf("string:\t"); scanf("%s",s1); /* we need to copy all the characters, and * the final NULL character! l = strlen(s1); /* rather than writing this loop we could also write strcpy(s2,s1) for (i = 0; i < l+1; ++i) S2[i] = S1[i]; /* change original S1 S1[0] = S1[1] = S1[2] = '*'; S1[3] = 0; /* print both strings

5 String Comparison /* What is the result of the following * for different strings S1, S2? char S1[MAX_STRING_LEN]; char S2[MAX_STRING_LEN]; int i, l, res; printf("string1:\t"); scanf("%s",s1); printf("string2:\t"); scanf("%s",s2); res = strcmp(s1,s2); printf("strcmp(%ss1,%ss2) = %d\n",s1,s2,res); Copying Strings /* Warning: Strings aren't regular variables * You've to be careful with string comparison * and assignments. char* S1 = "AAAAAAAAAA"; char* S2 = "BBBBBBBBBB"; int i, l; /* assign S1 to S2 S2 = S1; /* change S1 S1[0] = S1[1] = S1[2] = '*';

6 S1[3] = 0; /* print both strings Equality of Strings /* Warning: Strings aren't regular variables * You've to be careful with string comparison * and assignments. char* S1 = "AAAAAAAAAA"; char* S2 = "AAAAAAAAAA"; int cmp1, cmp2, cmp3, cmp4; cmp1 = (S1 == S2); cmp2 = strcmp(s1,s2); printf("s1 == S2:\t%d\n",cmp1); printf("strcmp(s1,s2):\t%d\n",cmp2); S2 = S1; cmp3 = (S1 == S2); cmp4 = strcmp(s1,s2); printf("\nafter assignment\n"); printf("s1 == S2:\t%d\n",cmp3); printf("strcmp(s1,s2):\t%d\n",cmp4); Strcat #define MAX_STRING_LENGTH 80 /* strcat is another useful command:

7 * it appends a copy of a second string char S1[MAX_STRING_LENGTH]; char S2[MAX_STRING_LENGTH]; strcat(s1,s2); printf("s1:\t"); scanf("%s",s1); printf("s2:\t"); scanf("%s",s2); strcat(s1,s2); printf("\nafter strcat(s1,s2)\n");

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

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

C Strings and Pointers

C Strings and Pointers Motivation The C++ string class makes it easy to create and manipulate string data, and is a good thing to learn when rst starting to program in C++ because it allows you to work with string data without

More information

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT COURSE CURRICULUM. Course Title: Advanced Computer Programming (Code: 3320702)

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT COURSE CURRICULUM. Course Title: Advanced Computer Programming (Code: 3320702) GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT COURSE CURRICULUM Course Title: Advanced Computer Programming (Code: 3320702) Diploma Programmes in which this course is offered Computer Engineering,

More information

Sources: On the Web: Slides will be available on:

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

5 Arrays and Pointers

5 Arrays and Pointers 5 Arrays and Pointers 5.1 One-dimensional arrays Arrays offer a convenient way to store and access blocks of data. Think of arrays as a sequential list that offers indexed access. For example, a list of

More information

Module 816. File Management in C. M. Campbell 1993 Deakin University

Module 816. File Management in C. M. Campbell 1993 Deakin University M. Campbell 1993 Deakin University Aim Learning objectives Content After working through this module you should be able to create C programs that create an use both text and binary files. After working

More information

Stacks. Linear data structures

Stacks. Linear data structures Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations

More information

60-141 Introduction to Programming II Winter, 2014 Assignment 2

60-141 Introduction to Programming II Winter, 2014 Assignment 2 60-141 Introduction to Programming II Winter, 2014 Assignment 2 Array In this assignment you will implement an encryption and a corresponding decryption algorithm which involves only random shuffling of

More information

Molecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct

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

Passing 1D arrays to functions.

Passing 1D arrays to functions. Passing 1D arrays to functions. In C++ arrays can only be reference parameters. It is not possible to pass an array by value. Therefore, the ampersand (&) is omitted. What is actually passed to the function,

More information

CS106A, Stanford Handout #38. Strings and Chars

CS106A, Stanford Handout #38. Strings and Chars CS106A, Stanford Handout #38 Fall, 2004-05 Nick Parlante Strings and Chars The char type (pronounced "car") represents a single character. A char literal value can be written in the code using single quotes

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

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

Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example

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

An Incomplete C++ Primer. University of Wyoming MA 5310

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

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

KITES TECHNOLOGY COURSE MODULE (C, C++, DS) KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL

More information

Written by the Red Hat Eclipse Engineering Team Revision 3. October 2003

Written by the Red Hat Eclipse Engineering Team Revision 3. October 2003 ! " $#&%'() Abstract This white paper provides information on Red Hat Developer Suite, a member of the Red Hat Applications product family. It describes the goals of Red Hat Developer Suite, the Eclipse

More information

arrays C Programming Language - Arrays

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

Chapter 13 - The Preprocessor

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

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasket { public static void main(string[]

More information

So far we have considered only numeric processing, i.e. processing of numeric data represented

So far we have considered only numeric processing, i.e. processing of numeric data represented Chapter 4 Processing Character Data So far we have considered only numeric processing, i.e. processing of numeric data represented as integer and oating point types. Humans also use computers to manipulate

More information

Informatica e Sistemi in Tempo Reale

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

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in

More information

EXEC SQL CONNECT :userid IDENTIFIED BY :passwd;

EXEC SQL CONNECT :userid IDENTIFIED BY :passwd; SQL with C Test Program 1: Select a row with one column int value; EXEC SQL select max (b) into :value from r; printf ("connected\n"); printf ("max (b) = %d\n", value); Ensure that your library path is

More information

The C Programming Language course syllabus associate level

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

Unit 1. 5. Write iterative and recursive C functions to find the greatest common divisor of two integers. [6]

Unit 1. 5. Write iterative and recursive C functions to find the greatest common divisor of two integers. [6] Unit 1 1. Write the following statements in C : [4] Print the address of a float variable P. Declare and initialize an array to four characters a,b,c,d. 2. Declare a pointer to a function f which accepts

More information

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands C Programming for Embedded Microcontrollers Warwick A. Smith Elektor International Media BV Postbus 11 6114ZG Susteren The Netherlands 3 the Table of Contents Introduction 11 Target Audience 11 What is

More information

MATLAB: Strings and File IO

MATLAB: Strings and File IO MATLAB: Strings and File IO Kipp Martin University of Chicago Booth School of Business February 9, 2012 The M-files The following files are used in this lecture. filein.txt fileio.m Outline Strings File

More information

Embedded Systems Design Course Applying the mbed microcontroller

Embedded Systems Design Course Applying the mbed microcontroller Embedded Systems Design Course Applying the mbed microcontroller Memory and data management These course notes are written by R.Toulson (Anglia Ruskin University) and T.Wilmshurst (University of Derby).

More information

Chapter 2: Elements of Java

Chapter 2: Elements of Java Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction

More information

Using C# for Graphics and GUIs Handout #2

Using C# for Graphics and GUIs Handout #2 Using C# for Graphics and GUIs Handout #2 Learning Objectives: C# Arrays Global Variables Your own methods Random Numbers Working with Strings Drawing Rectangles, Ellipses, and Lines Start up Visual Studio

More information

Software security. Buffer overflow attacks SQL injections. Lecture 11 EIT060 Computer Security

Software security. Buffer overflow attacks SQL injections. Lecture 11 EIT060 Computer Security Software security Buffer overflow attacks SQL injections Lecture 11 EIT060 Computer Security Buffer overflow attacks Buffer overrun is another common term Definition A condition at an interface under which

More information

Introduction to Programming

Introduction to Programming Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems sjmaybank@dcs.bbk.ac.uk Spring 2015 Week 2b: Review of Week 1, Variables 16 January 2015 Birkbeck

More information

Lecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists

Lecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists Lecture 11 Doubly Linked Lists & Array of Linked Lists In this lecture Doubly linked lists Array of Linked Lists Creating an Array of Linked Lists Representing a Sparse Matrix Defining a Node for a Sparse

More information

Application Security: Web service and E-Mail

Application Security: Web service and E-Mail Application Security: Web service and E-Mail (April 11, 2011) Abdou Illia Spring 2011 Learning Objectives Discuss general Application security Discuss Webservice/E-Commerce security Discuss E-Mail security

More information

Chapter 9, More SQL: Assertions, Views, and Programming Techniques

Chapter 9, More SQL: Assertions, Views, and Programming Techniques Chapter 9, More SQL: Assertions, Views, and Programming Techniques 9.2 Embedded SQL SQL statements can be embedded in a general purpose programming language, such as C, C++, COBOL,... 9.2.1 Retrieving

More information

Introduction to Java

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

CS193D Handout 06 Winter 2004 January 26, 2004 Copy Constructor and operator=

CS193D Handout 06 Winter 2004 January 26, 2004 Copy Constructor and operator= CS193D Handout 06 Winter 2004 January 26, 2004 Copy Constructor and operator= We already know that the compiler will supply a default (zero-argument) constructor if the programmer does not specify one.

More information

Time Limit: X Flags: -std=gnu99 -w -O2 -fomitframe-pointer. Time Limit: X. Flags: -std=c++0x -w -O2 -fomit-frame-pointer - lm

Time Limit: X Flags: -std=gnu99 -w -O2 -fomitframe-pointer. Time Limit: X. Flags: -std=c++0x -w -O2 -fomit-frame-pointer - lm Judge Environment Language Compilers Language Version Flags/Notes Max Memory Limit C gcc 4.8.1 Flags: -std=gnu99 -w -O2 -fomit-frame-pointer - lm C++ g++ 4.8.1 Flags: -std=c++0x -w -O2 -fomit-frame-pointer

More information

Tutorial on C Language Programming

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

Member Functions of the istream Class

Member Functions of the istream Class Member Functions of the istream Class The extraction operator is of limited use because it always uses whitespace to delimit its reads of the input stream. It cannot be used to read those whitespace characters,

More information

How 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)

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

Lexical Analysis and Scanning. Honors Compilers Feb 5 th 2001 Robert Dewar

Lexical Analysis and Scanning. Honors Compilers Feb 5 th 2001 Robert Dewar Lexical Analysis and Scanning Honors Compilers Feb 5 th 2001 Robert Dewar The Input Read string input Might be sequence of characters (Unix) Might be sequence of lines (VMS) Character set ASCII ISO Latin-1

More information

3 IDE (Integrated Development Environment)

3 IDE (Integrated Development Environment) Visual C++ 6.0 Guide Part I 1 Introduction Microsoft Visual C++ is a software application used to write other applications in C++/C. It is a member of the Microsoft Visual Studio development tools suite,

More information

XMOS Programming Guide

XMOS Programming Guide XMOS Programming Guide Document Number: Publication Date: 2014/10/9 XMOS 2014, All Rights Reserved. XMOS Programming Guide 2/108 SYNOPSIS This document provides a consolidated guide on how to program XMOS

More information

System Calls Related to File Manipulation

System Calls Related to File Manipulation KING FAHD UNIVERSITY OF PETROLEUM AND MINERALS Information and Computer Science Department ICS 431 Operating Systems Lab # 12 System Calls Related to File Manipulation Objective: In this lab we will be

More information

About The Tutorial. Audience. Prerequisites. Copyright & Disclaimer

About The Tutorial. Audience. Prerequisites. Copyright & Disclaimer About The Tutorial C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system.

More information

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

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

8.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.

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

Basics of I/O Streams and File I/O

Basics of I/O Streams and File I/O Basics of This is like a cheat sheet for file I/O in C++. It summarizes the steps you must take to do basic I/O to and from files, with only a tiny bit of explanation. It is not a replacement for reading

More information

File Handling. What is a file?

File Handling. What is a file? File Handling 1 What is a file? A named collection of data, stored in secondary storage (typically). Typical operations on files: Open Read Write Close How is a file stored? Stored as sequence of bytes,

More information

As previously noted, a byte can contain a numeric value in the range 0-255. Computers don't understand Latin, Cyrillic, Hindi, Arabic character sets!

As previously noted, a byte can contain a numeric value in the range 0-255. Computers don't understand Latin, Cyrillic, Hindi, Arabic character sets! Encoding of alphanumeric and special characters As previously noted, a byte can contain a numeric value in the range 0-255. Computers don't understand Latin, Cyrillic, Hindi, Arabic character sets! Alphanumeric

More information

Object-Oriented Programming in Java

Object-Oriented Programming in Java CSCI/CMPE 3326 Object-Oriented Programming in Java Class, object, member field and method, final constant, format specifier, file I/O Dongchul Kim Department of Computer Science University of Texas Rio

More information

The programming language C. sws1 1

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

Computer Programming Tutorial

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

Comp151. Definitions & Declarations

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

Object oriented programming. Course Objectives. On completion of the class, a student should be able: Object Oriented Paradigm

Object oriented programming. Course Objectives. On completion of the class, a student should be able: Object Oriented Paradigm Object oriented programming Course Objectives Object Oriented Paradigm C/C++ Programming Language On completion of the class, a student should be able: to prepare object-oriented design for small/medium

More information

Microcontroller Systems. ELET 3232 Topic 8: Slot Machine Example

Microcontroller Systems. ELET 3232 Topic 8: Slot Machine Example Microcontroller Systems ELET 3232 Topic 8: Slot Machine Example 1 Agenda We will work through a complete example Use CodeVision and AVR Studio Discuss a few creative instructions Discuss #define and #include

More information

Symbol Tables. Introduction

Symbol Tables. Introduction Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The

More information

System Calls and Standard I/O

System Calls and Standard I/O System Calls and Standard I/O Professor Jennifer Rexford http://www.cs.princeton.edu/~jrex 1 Goals of Today s Class System calls o How a user process contacts the Operating System o For advanced services

More information

Introduction to Data Structures

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

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

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction Standard 2: Technology and Society Interaction Technology and Ethics Analyze legal technology issues and formulate solutions and strategies that foster responsible technology usage. 1. Practice responsible

More information

Lecture 5: Java Fundamentals III

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

Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11

Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11 Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11 In this lab, you will first learn how to use pointers to print memory addresses of variables. After that, you will learn

More information

C PROGRAMMING FOR MATHEMATICAL COMPUTING

C PROGRAMMING FOR MATHEMATICAL COMPUTING UNIVERSITY OF CALICUT SCHOOL OF DISTANCE EDUCATION BSc MATHEMATICS (2011 Admission Onwards) VI Semester Elective Course C PROGRAMMING FOR MATHEMATICAL COMPUTING QUESTION BANK Multiple Choice Questions

More information

Parallel Computing. Shared memory parallel programming with OpenMP

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

Introduction to Python

Introduction to Python WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

More information

Stack Allocation. Run-Time Data Structures. Static Structures

Stack Allocation. Run-Time Data Structures. Static Structures Run-Time Data Structures Stack Allocation Static Structures For static structures, a fixed address is used throughout execution. This is the oldest and simplest memory organization. In current compilers,

More information

Introduction to Perl

Introduction to Perl Introduction to Perl March 8, 2011 by Benjamin J. Lynch http://msi.umn.edu/~blynch/tutorial/perl.pdf Outline What Perl Is When Perl Should Be used Basic Syntax Examples and Hands-on Practice More built-in

More information

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2014 Jill Seaman

More information

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement? 1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members

More information

CS107L Handout 02 Autumn 2007 October 5, 2007 Copy Constructor and operator=

CS107L Handout 02 Autumn 2007 October 5, 2007 Copy Constructor and operator= CS107L Handout 02 Autumn 2007 October 5, 2007 Copy Constructor and operator= Much of the surrounding prose written by Andy Maag, CS193D instructor from years ago. The compiler will supply a default (zero-argument)

More information

Simple C Programs. Goals for this Lecture. Help you learn about:

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

SQL is capable in manipulating relational data SQL is not good for many other tasks

SQL is capable in manipulating relational data SQL is not good for many other tasks Embedded SQL SQL Is Not for All SQL is capable in manipulating relational data SQL is not good for many other tasks Control structures: loops, conditional branches, Advanced data structures: trees, arrays,

More information

Computer Systems II. Unix system calls. fork( ) wait( ) exit( ) How To Create New Processes? Creating and Executing Processes

Computer Systems II. Unix system calls. fork( ) wait( ) exit( ) How To Create New Processes? Creating and Executing Processes Computer Systems II Creating and Executing Processes 1 Unix system calls fork( ) wait( ) exit( ) 2 How To Create New Processes? Underlying mechanism - A process runs fork to create a child process - Parent

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 01 / 29 / 2014 Instructor: Michael Eckmann Today s Topics Comments and/or Questions? import user input using JOptionPane user input using Scanner psuedocode import

More information

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6) Semantic Analysis Scoping (Readings 7.1,7.4,7.6) Static Dynamic Parameter passing methods (7.5) Building symbol tables (7.6) How to use them to find multiply-declared and undeclared variables Type checking

More information

Chapter 13 Storage classes

Chapter 13 Storage classes Chapter 13 Storage classes 1. Storage classes 2. Storage Class auto 3. Storage Class extern 4. Storage Class static 5. Storage Class register 6. Global and Local Variables 7. Nested Blocks with the Same

More information

Java from a C perspective. Plan

Java from a C perspective. Plan Java from a C perspective Cristian Bogdan 2D2052/ingint04 Plan Objectives and Book Packages and Classes Types and memory allocation Syntax and C-like Statements Object Orientation (minimal intro) Exceptions,

More information

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

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

2 ASCII TABLE (DOS) 3 ASCII TABLE (Window)

2 ASCII TABLE (DOS) 3 ASCII TABLE (Window) 1 ASCII TABLE 2 ASCII TABLE (DOS) 3 ASCII TABLE (Window) 4 Keyboard Codes The Diagram below shows the codes that are returned when a key is pressed. For example, pressing a would return 0x61. If it is

More information

Embedded C Programming

Embedded C Programming Microprocessors and Microcontrollers Embedded C Programming EE3954 by Maarten Uijt de Haag, Tim Bambeck EmbeddedC.1 References MPLAB XC8 C Compiler User s Guide EmbeddedC.2 Assembly versus C C Code High-level

More information

1 Abstract Data Types Information Hiding

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

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine 7 Objectives After completing this lab you will: know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine Introduction Branches and jumps provide ways to change

More information

Environnements et Outils de Développement Cours 6 Building with make

Environnements et Outils de Développement Cours 6 Building with make Environnements et Outils de Développement Cours 6 Building with make Stefano Zacchiroli zack@pps.univ-paris-diderot.fr Laboratoire PPS, Université Paris Diderot URL http://upsilon.cc/zack/teaching/1314/ed6/

More information

Education: P.h.D. Candidate (Santa Clara University, California) M.S. in Computer Engineering (Santa Clara University, California)

Education: P.h.D. Candidate (Santa Clara University, California) M.S. in Computer Engineering (Santa Clara University, California) Instructor: Professor Neena Kaushik Education: P.h.D. Candidate (Santa Clara University, California) M.S. in Computer Engineering (Santa Clara University, California) M.S. in Biomedical Engineering (Northwestern

More information

Outline Basic concepts of Python language

Outline Basic concepts of Python language Data structures: lists, tuples, sets, dictionaries Basic data types Examples: int: 12, 0, -2 float: 1.02, -2.4e2, 1.5e-3 complex: 3+4j bool: True, False string: "Test string" Conversion between types int(-2.8)

More information

Computer Science Questions and Answers UNIT-A Chapter - 1 Configuring a Computer

Computer Science Questions and Answers UNIT-A Chapter - 1 Configuring a Computer I One Mark Question and Answer 1. Name the components of CPU Computer Science Questions and Answers UNIT-A Chapter - 1 Configuring a Computer Ans. a) ALU b) PC c) Accumulator d) MAR e) IR f) ID g) MDR

More information

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

64-Bit NASM Notes. Invoking 64-Bit NASM

64-Bit NASM Notes. Invoking 64-Bit NASM 64-Bit NASM Notes The transition from 32- to 64-bit architectures is no joke, as anyone who has wrestled with 32/64 bit incompatibilities will attest We note here some key differences between 32- and 64-bit

More information

An Implementation of a Tool to Detect Vulnerabilities in Coding C and C++

An Implementation of a Tool to Detect Vulnerabilities in Coding C and C++ An Implementation of a Tool to Detect Vulnerabilities in Coding C and C++ GRADUATE PROJECT REPORT Submitted to the Faculty of The School of Engineering & Computing Sciences Texas A&M University-Corpus

More information

CMSC 202H. ArrayList, Multidimensional Arrays

CMSC 202H. ArrayList, Multidimensional Arrays CMSC 202H ArrayList, Multidimensional Arrays What s an Array List ArrayList is a class in the standard Java libraries that can hold any type of object an object that can grow and shrink while your program

More information

RTI Monitoring Library Getting Started Guide

RTI Monitoring Library Getting Started Guide RTI Monitoring Library Getting Started Guide Version 5.1.0 2011-2013 Real-Time Innovations, Inc. All rights reserved. Printed in U.S.A. First printing. December 2013. Trademarks Real-Time Innovations,

More information

1 Stored Procedures in PL/SQL 2 PL/SQL. 2.1 Variables. 2.2 PL/SQL Program Blocks

1 Stored Procedures in PL/SQL 2 PL/SQL. 2.1 Variables. 2.2 PL/SQL Program Blocks 1 Stored Procedures in PL/SQL Many modern databases support a more procedural approach to databases they allow you to write procedural code to work with data. Usually, it takes the form of SQL interweaved

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper

More information

Illustration 1: Diagram of program function and data flow

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

public static void main(string[] args) { System.out.println("hello, world"); } }

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