Systems Programming Concepts

Slides:



Advertisements
Similar presentations
1 Chapter Thirteen Pointers. 2 Pointers A pointer is a sign used to point out the direction.
Advertisements

Strings Input/Output scanf and printf sscanf and sprintf gets and puts.
1 Chapter 10 Strings and Pointers. 2 Introduction  String Constant  Example: printf(“Hello”); “Hello” : a string constant oA string constant is a series.
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
By Senem Kumova Metin 1 POINTERS + ARRAYS + STRINGS REVIEW.
1 CSE1301 Computer Programming Lecture 16 Pointers.
C Strings Systems Programming. Systems Programming: Strings 22 StringsStrings  Strings versus Single characters  Pointers versus Arrays  Accessing.
C Strings Systems Programming. Systems Programming: Strings 22 StringsStrings  Strings versus Single characters  Pointers versus Arrays  Accessing.
1 CSE1301 Computer Programming Lecture 16 Pointers.
What are Pointers? Different from other normal variables which can store values. pointers are special variables that can hold the address of a variable.
ARRAYS In this Lecture, we will try to develop understanding of some of the relatively complex concepts. The following are explained in this lecture with.
Chapter 9 Character Strings 9.1 Character String Constants A character string constant is a sequence of characters enclosed in double quotation mark. Examples.
Introduction to Programming Using C Files. 2 Contents Files Working with files Sequential files Records.
Xuan Guo Review for the Final Exam Xuan Guo July 29 8:30AM – 10:30AM Classroom South 300 CSC
One-dimensional arrays and strings: Chapter 6, Slide 1 The concept of array - an extension of the basic model of memory:
Pointers in C++. Topics Covered  Introduction to Pointers  Pointers and arrays  Character Pointers, Arrays and Strings  Examples.
Department of Electronic & Electrical Engineering IO reading and writing variables scanf printf format strings "%d %c %f"
Chapter 16 Pointers and Arrays Pointers and Arrays We've seen examples of both of these in our LC-3 programs; now we'll see them in C. Pointer Address.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic properties and characteristics of external files ❏ To.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Arrays Outline 6.1Introduction 6.2Arrays 6.3Declaring.
University of Malta CSA2090: Lecture 5 © Chris Staff 1 of 22 CSA2090: Systems Programming Introduction to C Dr. Christopher Staff.
Pointers and Classes.
Pointers What is the data type of pointer variables?
char first[10]="monkey"; char second[10]="fish"; char* keep;
Pointers and Dynamic Arrays
Chapter 8 Arrays, Strings and Pointers
Pointers & Arrays 1-d arrays & pointers 2-d arrays & pointers.
Strings (Continued) Chapter 13
Characters and Strings
Lecture 8 String 1. Concept of strings String and pointers
Chapter 7 Text Input/Output Objectives
Command Line Arguments
Command Line Arguments
Tutorial 8 Pointers and Strings
Strings A string is a sequence of characters treated as a group
Chapter 9 Pointers Objectives
Programming Languages and Paradigms
CSI-121 Structured Programming Language Lecture 16 Pointers
Lecture 11: Strings B Burlingame 11 April 2018.
Buy book Online -
LINKED LISTS.
CS111 Computer Programming
C Stuff CS 2308.
Dale Roberts, Lecturer IUPUI
Chapter 9 - Arrays Outline 6.1 Introduction 6.2 Arrays
INC 161 , CPE 100 Computer Programming
Character & String Knowledge
Dynamic Memory Allocation
C Characters and Strings – Review Lab assignments
Systems Programming Concepts
Arrays Strings and Parameter Passing CSCI N305
By Hector M Lugo-Cordero September 17, 2008
Chapter 16 Pointers and Arrays
Strings Chapter 13 Copyright © 2008 W. W. Norton & Company.
Chapter 8 Character Arrays and Strings
ECE 103 Engineering Programming Chapter 51 Random Numbers
ECE 103 Engineering Programming Chapter 25 C Strings, Part 1
ECE 103 Engineering Programming Chapter 46 argc, argv, envp
POINTER CONCEPT 4/15/2019.
CS250 Introduction to Computer Science II
EECE.2160 ECE Application Programming
Chapter 9: Pointers and String
Lecture 19: Working with strings
Character Arrays char string1[] = “first”;
ㅎㅎ Sixth step for Learning C++ Programming Pointer new, delete String
Characters and Strings
POINTER CONCEPT 8/3/2019.
Structures, Unions, and Enumerations
Chapter 5: Hashing Hash Tables
Files Chapter 8.
Presentation transcript:

Systems Programming Concepts C Strings Systems Programming Concepts

Strings Strings versus Single characters Pointers versus Arrays Accessing Array of Strings with Pointers Systems Programming Strings 2

Strings Strings are arrays of characters treated as a single unit and terminated by ‘\0’ (null). The \0 occupies one char in the array of characters. H e l l o \0 Systems Programming Strings 3

Strings A string is accessed by a pointer to the first character in the string. Since the value of a string is the address of its first character, in C a string is a pointer! Systems Programming Strings

Character Strings char c = ‘W’; c char *s = “George Bush”; char s2[] = “Hillary”; s2 W H i l l a r y \0 Systems Programming Strings

Character Strings s2[0] = ‘B’; s2[4] = ‘\0’; S2 printf(“%s\n”, s2); B l l \0 r y \0 Systems Programming Strings

Character Strings A string can be stored into an array using scanf. char president[20]; scanf (“%s”, president); Systems Programming Strings

An Array of Strings Example /* An Example of an Array of Strings accessed using a string pointer */ int main () { int i,j; char let = 'A'; char cray [3][10]; char *cptr[3]; for (j=0; j<3; j++) cptr[j] = &cray [j][0]; { let = let +1; for (i=0; i<9; i++) cray [j][i] = let + i; cray [j][9] = '\0'; } printf("j = %d, char = %s\n", j, cptr[j]); return 0; ./charray j = 0, char = BCDEFGHIJ j = 1, char = CDEFGHIJK j = 2, char = DEFGHIJKL Systems Programming Strings

More on Strings!! not right now Read parts of Chapter 8 for Program 4 Systems Programming Strings