C Strings Systems Programming. Systems Programming: Strings 22 StringsStrings  Strings versus Single characters  Pointers versus Arrays  Accessing.

Slides:



Advertisements
Similar presentations
C++ crash course Class 10 practice problems. Pointers The following function is trying to swap the contents of two variables. Why isnt it working? void.
Advertisements

LECTURE 17 C++ Strings 18. 2Strings Creating String Objects 18 C-string C++ - string \0 Array of chars that is null terminated (‘\0’). Object.
1 Chapter 10 Strings and Pointers. 2 Introduction  String Constant  Example: printf(“Hello”); “Hello” : a string constant oA string constant is a series.
Lecture 09 Strings, IDEs. METU Dept. of Computer Eng. Summer 2002 Ceng230 - Section 01 Introduction To C Programming by Ahmet Sacan Mon July 29, 2002.
String in C++. String Series of characters enclosed in double quotes.“Philadelphia University” String can be array of characters ends with null character.
Chapter Fourteen Strings Revisited. Strings A string is an array of characters A string is a pointer to a sequence of characters A string is a complete.
By Senem Kumova Metin 1 POINTERS + ARRAYS + STRINGS REVIEW.
Pointer, malloc and realloc 1. Name entered was 6 char, not enough space to put null terminator 2 Array of char.
C workshop #3 flow control / strings.
CIS 101: Computer Programming and Problem Solving Lecture10 Usman Roshan Department of Computer Science NJIT.
Pointers and Arrays C and Data Structures Baojian Hua
Презентація за розділом “Гумористичні твори”
Центр атестації педагогічних працівників 2014
Галактики і квазари.
Характеристика ІНДІЇ.
Процюк Н.В. вчитель початкових класів Боярської ЗОШ І – ІІІ ст №4
Tutorial #8 Summer strings #include int main() { char str1[] = {‘h’,’e’,’l’,’l’,’o’}; char str[] = {‘h’,’e’,’l’,’l’,’o’,’\0’}; char p[] = ”hello”;
C Strings Systems Programming. Systems Programming: Strings 22 StringsStrings  Strings versus Single characters  Pointers versus Arrays  Accessing.
CS1061 C Programming Lecture 15: More on Characters and Strings A. O’Riordan, 2004.
Command line arguments. – main can take two arguments conventionally called argc and argv. – Information regarding command line arguments are passed to.
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.
POINTERS. 1.a) POINTER EXPRESSIONS Pointer variables can be used in expression If p1 and p2 are properly declared and initialized pointers then following.
CPT: Arrays of Pointers/ Computer Programming Techniques Semester 1, 1998 Objectives of these slides: –to illustrate the use of arrays.
 2000 Prentice Hall, Inc. All rights reserved Arrays Array –Group of consecutive memory locations –Same name and type To refer to an element, specify.
C Programming Lecture 10-1 : Array & Pointer. Character Array String A sequence of characters The last character should be ‘\0’ that indicates “the end.
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.
ENEE150 – 0102 ANDREW GOFFIN Strings. Project 2 Flight Database 4 options:  Print flight  Print airport  Find non-stop flights  Find one-stop flights.
CSCI 130 More on Arrays. Multi-dimensional Arrays Multi - Dimensional arrays: –have more than one subscript –can be directly initialized –can be initialized.
Review (before the 1 st test): while (conditions) { statements; } while loop: if/else if/else statements: if (conditions) { statements; } else if (different.
Dr. Yang, QingXiong (with slides borrowed from Dr. Yuen, Joe) LT:10 Advance Pointer Array, String and Dynamic Memory Allocation CS2311 Computer Programming.
Multidimensional Arrays tMyn1 Multidimensional Arrays It is possible to declare arrays that require two or more separate index values to access an element.
 Learn how to form strings using one-dimensional array  String manipulation functions:  strcpy  strrev  strcmp  Program using strings.
Current Assignments Project 3 has been posted, due next Tuesday. Write a contact manager. Homework 6 will be posted this afternoon and will be due Friday.
Introduction to Programming Lecture 12. Today’s Lecture Includes Strings ( character arrays ) Strings ( character arrays ) Algorithms using arrays Algorithms.
University of Malta CSA2090: Lecture 5 © Chris Staff 1 of 22 CSA2090: Systems Programming Introduction to C Dr. Christopher Staff.
Week 6 - Friday.  What did we talk about last time?  Pointers  Passing values by reference.
Command Line Arguments
Command Line Arguments
Programming Languages and Paradigms
Lecture 11: Strings B Burlingame 11 April 2018.
Systems Programming Concepts
Проф. д-р Васил Цанов, Институт за икономически изследвания при БАН
ЗУТ ПРОЕКТ на Закон за изменение и допълнение на ЗУТ
О Б Щ И Н А С И Л И С Т Р А П р о е к т Б ю д ж е т г.
Електронни услуги на НАП
Боряна Георгиева – директор на
РАЙОНЕН СЪД - БУРГАС РАБОТНА СРЕЩА СЪС СЪДЕБНИТЕ ЗАСЕДАТЕЛИ ПРИ РАЙОНЕН СЪД – БУРГАС 21 ОКТОМВРИ 2016 г.
Сътрудничество между полицията и другите специалисти в България
Съобщение Ръководството на НУ “Христо Ботев“ – гр. Елин Пелин
НАЦИОНАЛНА АГЕНЦИЯ ЗА ПРИХОДИТЕ
ДОБРОВОЛЕН РЕЗЕРВ НА ВЪОРЪЖЕНИТЕ СИЛИ НА РЕПУБЛИКА БЪЛГАРИЯ
Съвременни софтуерни решения
ПО ПЧЕЛАРСТВО ЗА ТРИГОДИШНИЯ
от проучване на общественото мнение,
Васил Големански Ноември, 2006
Програма за развитие на селските райони
ОПЕРАТИВНА ПРОГРАМА “АДМИНИСТРАТИВЕН КАПАЦИТЕТ”
БАЛИСТИКА НА ТЯЛО ПРИ СВОБОДНО ПАДАНЕ В ЗЕМНАТА АТМОСФЕРА
МЕДИЦИНСКИ УНИВЕРСИТЕТ – ПЛЕВЕН
Стратегия за развитие на клъстера 2015
Моето наследствено призвание
Правна кантора “Джингов, Гугински, Кючуков & Величков”
Безопасност на движението
ECE 103 Engineering Programming Chapter 51 Random Numbers
EECE.2160 ECE Application Programming
Character Arrays char string1[] = “first”;
Systems Programming Concepts
Presentation transcript:

C Strings Systems Programming

Systems Programming: Strings 22 StringsStrings  Strings versus Single characters  Pointers versus Arrays  Accessing Array of Strings with Pointers

Systems Programming: Strings 33 Strings  Strings are arrays of characters terminated by ‘\0’ (null).  The \0 occupies one char in the array of characters. Hell\0o

Systems Programming: Strings 4 Character Strings char c = ‘W’; c char *s = “George Bush” char s2[] = “Hillary” s2 W Hill\0ary

Systems Programming: Strings 5 Character Strings Bill \0 ry s2[0] = ‘B’; s2[4] = ‘\0’; S2 printf(“%s\n”, s2);

Systems Programming: Strings 6 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]; for (j=0; j<3; j++) { let = let +1; for (i=0; i<9; i++) cray [j][i] = let + i; cray [j][9] = '\0'; } for (j=0; j<3; j++) printf("j = %d, char = %s\n", j, cptr[j]); return 0; }./charray j = 0, char = BCDEFGHIJ j = 1, char = CDEFGHIJK j = 2, char = DEFGHIJKL