Chapter 8 C Characters and Strings

Size: px
Start display at page:

Download "Chapter 8 C Characters and Strings"

Transcription

1 Chapter 8 C Characters and Strings

2 Objectives of This Chapter To use the functions of the character handling library (<ctype.h>). To use the string conversion functions of the general utilities library (<stdlib.h>). To use the string and character input/output functions of the standard input/output library (<stdio.h>). To use the string processing functions of the string handling library (<string.h>). The power of function libraries for achieving software reusability.

3 Page 342 CHARACTERS: Characters are the fundamental building blocks of source programs. Every program is composed of a sequence of characters that when grouped together meaningfully is interpreted by the computer as a series of instructions used to accomplish a task. Computers are designed to work with numbers, so computers deal with the characters in terms of character constants. A character constant is an int value represented as a character in single quotes. The value of a character constant is the integer value of the character in the machine s character set commonly referred as ASCII table. ASCII stands for American Standard Code for Information Interchange. In C, a character is expressed in single quotation marks. ( char a=`y`). For example: 'z' represents the integer value of z, and '\n' the integer value of newline are 122 and 10 in ASCII, respectively.

4 ASCII TABLE : Character Constants in Machine Language are listed below referred as ASCII TABLE. \0 is NULL character. \33 is! character. \65 is A character. The Ascii Table is worldwide accepted and standard for the all computer systems. Most of character manipulation operations are done based on this table.

5 ASCII CHARACTER TABLE : Conversion Programs Programs to convert a character to ASCII number and ASCII number to character.** * Output of the Program * * Output of the Program *

6 More on ASCII TABLE Character Constants As one may notice from Table: Characters are grouped in meaningful ordered.*** For instance; 47 < Digits < < Alphabetic Upper Case < < Alphabetic Lower Case < 123 By considering that the digits, letters, fall into a range. One may classify/manipulate the characters based on their ASCII number.* Example: Program that converts a Character from Lower Case to Upper Case char c=`o`; // Note that ASCII number for `o` is 111. if ( c > 96 && c < 123){ // Note that 96 < Alphabetic Lower Case < 123 c =32; // This assign the ASCII number = 79 printf( %c,c); // This will print This kind of functions are available under C libraries we will learn how to use them

7 Page 342 STRINGS: Strings are collection of characters. Strings may include letters (a, Z, c, etc.), digits (0,8,7, etc.), or various special characters (:,., *, +, &, etc). In C, strings are written in double quotation marks. In C programming, we treat strings as characters arrays. Always last element of a string is a null character ( \0 ). In C, we may also deal with strings using string pointers ( char * ). Initialization of a string array can be done in different ways; char color[] = "blue"; // initializing by a string (double quotation marks). char *colorptr = "blue"; // initializing string pointer char color[] = { 'b', 'l', 'u', 'e', '\0' }; // initializing by characters (single quotation marks). scanf ( %s,color); // reading from keyboard (first element = mem. Add.)

8 Page 344 In some programs, we may need to identify or manipulate characters or strings. There are various libraries including function to deal with characters. The character handling library (ctype.h) presents several function to test/classify (test what type of character) and modify a character data. Test/Classification Functions: isdigit, isalpha, isalnum, isxdigit, islower, isupper, isspace, iscntrl, etc. The test functions receives a character (constant character) as argument. Returns: TRUE (1 or non zero in logic) if the result of test is true. FALSE (0 in logic) if the result of the test is false. Manipulation/Conversion Functions: toupper and tolower. Manipulation functions also receives character as argument (as constant character) then returns the value after conversion.

9 Complete list of character handling library (ctype.h) functions: Page 344

10 CONDITIONAL OPERATOR :? : Condition? Exp1 : Exp2 Similar to usage of single if else statement one may also use conditional operator? : to do the same task. If ( condition ) {Expression 1} else {Expression 2 } condition? Expression 1 : Expression 2 ; Means Do Expression 1 if TRUE otherwise Do Expression 2 Example: Showing some of the usage of conditional expressions printf("%d",x > y? x : y ); // print the value of x if bigger, otherwise print y z = x > y? x : y; // assing the value of x to z if bigger, otherwise assign y x > y? x++ : y++; //increase x by 1 if bigger otherwise increase y by 1

11 Example: Usage of CONDITIONAL OPERATOR :? : What will be the output of the following program?* * Output of the Program *

12 Example: Functions isdigit, isalpha, isalnum, and isxdigit Page 345 Following program demonstrates the usage of functions* * Output of the Program *

13 Example: Functions islower, isupper, tolower, and toupperpage 345 Following program demonstrates the usage of functions* * Output of the Program *

14 Example: Functions isspace, iscntrl, ispunct, isprint and isgraph Page 347 Following program demonstrates the usage of functions* * Output of the Program *

15 STRING MANUPILATION LIBRARIES Character Handling Library functions can be used only for characters (single character variables). As we know, the Strings are collection of characters. Strings may include letters (a, Z, c, etc.), digits (0,8,7, etc.), or various special characters (:,., *, +, &, etc). There are also other functions in C libraries; these functions enable the programmers to manipulate the strings (set of characters character arrays instead of only one character), which useful in most programs. Most of library functions associate with string operations will be presented in this chapter.

16 Page 349 This section presents the string conversion functions from the general utilities library (<stdlib.h>). This libraries can be used to convert a string of digits to double, integer, long integer, unsigned long integer. Why we should ever need to store numbers in a string? Remember: 999 Main Street or consider processing a complete line.

17 Function atof ( a string to a double) Page 350 atof function converts its argument (input) to a double number. Inputted string should consist of digits with floating point representing a meaningful double number, otherwise the behavior of atof function will be undefined. * * Output of the Program *

18 Function atoi ( a string to an integer) Page 350 atoi function converts its argument (input) to an integer number. Inputted string should consist of digits representing a meaningful integer number, otherwise the behavior of atoi function will be undefined. * * Output of the Program *

19 Function atol ( a string to a long int.) Page 351 atol function converts its argument (input) to a long integer number. Inputted string should consist of digits representing a meaningful long integer number, otherwise the behavior of atol function will be undefined. * * Output of the Program *

20 Function strtod ( seq. of char. to a double) Page 351 Similar to atod, strtod function also used to convert a string to a double number. But strtod is capable of processing a sequence of characters (string) partially including a double number. It accepts two arguments, first arguments is the string to be converted and second one is a character pointer that will be pointed by strtod to the remainder of string after conversion.* * Output of the Program *

21 Function strtol ( seq. of char. to a long integer ) Page 352 Similar to atol, strtol function also used to convert a string to a long integer number. But strtol is capable of processing a sequence of characters (string) partially including a meaningful long integer. It accepts three arguments, first arguments is the string to be converted, second one is a character pointer that will be pointed by strtol to the character positioned after the long integer, and third argument is the base (0 36) of number system. (Decimal:0 or10, Octal (8), Binary (2), Hex (16)) * * Output of the Program *

22 Function strtoul ( seq. of char. to a unsigned long integer) Page 353 strtoul function can be used to convert a string partially including an unsigned long integer number to an unsigned long integer number. It works pretty much similar to strtol function in terms of arguments (string, remainder, and base). * Output of the Program *

23 Page 354 This section presents several functions from the standard input/output library (<stdio.h>). These functions specifically can be used to input and manipulate string variables. Below table summaries arguments and return values of these functions.

24 Function fgets and putchar Explanation Page 355 Example: stream stdin is used to imply the keyboard can be also used as file. char sentence[ 80 ]; /* create char array */ fgets( sentence, 80, stdin ); /* using fgets to read line of text until \n newline*/ Example: Using putchar to print a single character to screen char str[ ] = Welcome to computer World! ; /* create char array */ int i=0; while ( ++i!= `\0`) putchar ( str[i]); /* using putchar to printing the string*/ another example; putchar (! ); /* using putchar to print single character! */

25 Function fgets and putchar Example Program Page 356 * Output of the Program *

26 Function getchar and puts Explanation Page 355 Example: getchar can be used to read a single character from keyboard. char a; /* define a single character variable */ a=getchar() /* using getchar to read a single char from keyboard it is load to a*/ putchar(a); /* using putchar to print the char variable */ getchar alternatives are getch() and getche() another example; char string[ 80 ] ; /* create char array */ int i=0; while ( ( string[i] = getch() )!= \n ) { i++ ; } /* Inputting whole line into string character */ Example: puts prints a string to a the screen followed by new line character char str[ ] = Welcome to computer World! ; /* create char array */ puts( str ); /* printing the string same as printf( %s\n,str); */ another example; puts( Welcome ); /* printing the string same as printf( %s\n, Welcome ); */

27 Function getchar and puts Example Program Page 356 * Output of the Program *

28 Function sprintf Explanation Page 357 sprintf works same as printf but it writes into a string instead of the screen. Example: sprintf can be used to write variable/s into a string array. char str[ 80 ] ; /* create char array */ int x = 100; double y = 3.4; printf( %5d%5.2d, x, y); /* print the variables to screen*/ sprintf( str, %5d%5.2d, x, y); /* print the variables to str string*/

29 Function sprintf Example Page 357 * Output of the Program *

30 Function sscanf Explanation Page 357 sscanf works same as scanf but it reads from a string instead of the screen. Example: sscanf can be used to read variable/s from a string array. char str[ 80 ] = 112 Ahmet ; /* create char array */ char name[30]; int x; scanf( %d%s, &x, name); /* reading the variables from keyboard*/ sscanf( str, %d%s, &x, name); /* reading the variables from the str string */

31 Function sscanf Example Page 358 * Output of the Program *

32 Page 358 The string handling library (<string.h>) provides many useful functions to manipulate string data. In this section, we will learn these functions in detail. (Copying Concatenating Separating Length of a String) Below table summaries arguments and return values of these functions.

33 Function strcpy and strncpy Explanation Page 359 Example: strcpy ( s1, s2 ) copies s2 string to s1 string. char str1[10], str2[]= Welcome ; /* defining two strings */ strcpy ( str1, str2 ); /* Copying str2 into str1 */ another example; char str[ 40 ] ; /* create char array */ strcpy ( str, Gaziantep / Sahinbey ); Example: strncpy ( s1, s2, n ) Copies n byte of data (1 character = 1 Byte) from s2 to s1. char str1[10], str2[]= Welcome ; /* defining two strings */ strncpy ( str1, str2, 3); /* Copying 3 character from str2 into str1 */ Note: If the n is less then the size of the str2, it doesn t \0 character.

34 Function strcpy and strncpy Example Program Page 359 * Output of the Program *

35 Function strcat and strncat Explanation Page 360 Example: strcat ( s1, s2 ) Append/Add s2 string to s1 string It starts appending from the `\0` of the s1. char str1[30]= James, str2[]= Polansky ; /* defining two strings */ strcat ( str1, str2 ); /* Appends str2 into str1 */ str2 becomes James Polansky Example: strncat ( s1, s2, n ) Appends n character from s2 to s1. char str1[30]= James, str2[]= Polansky ; /* defining two strings */ strncat ( str1, str2, 3); /* Appending 3 characters from str2 to str1 */ Note: If the n is less then the size of the str2, it doesn t append \0 character.

36 Function strcat and strncat Example Program Page 360 * Output of the Program *

37 Page 361 The string handling library (<string.h>) also provides function those can be used to compare two strings character by character. Below table summaries usage and the brief description these functions.

38 Function strcmp and strncmp Explanation Page 361 Example: strcmp ( s1, s2 ) compares s2 string to s1 string. char str1[]= Ali, str2[]= Ahmet ; /* defining two strings */ int result; result = strcmp ( str1, str2 ); /* Comparing str2 into str1 */ if str1 and str2 are same then result is 0. if str1 is greater than str2 are same then result is > 0. if str1 is less than str2 are same then result is < 0. strncmp ( s1, s2, n ) same as strcmp but compares only n characters. Note: Greater and Less means the alphabetical ordering or the strings. The function uses the ASCII codes of each characters. This functions can be used to order strings alphebetically.

39 Function strcmp and strncmp Example Program Page 361 * Output of the Program *

40 Page 363 The string handling library (<string.h>) also provides function those can be used to search characters or strings in another string. Below table summaries usage and the brief description these functions. Here; We will only present strchr, strstr, and strtok functions. You should review examples for the other functions and learn by your own.

41 Function strchr Explanation Page 364 Example: strchr ( s, c ) If character not included in string returns NULL char str[]= Gaziantep ; /* defining two strings */ char c = n ; /* defining a character variable */ if ( strchr ( str, c )! = NULL ) printf( %c is found in %s, c, str ); else printf( %c is not found in %s, c, str ); Because n exist in Gaziantep, it will print to screen n is found in Gaziantep

42 Function strchr Example Program Page 364 * Output of the Program *

43 Function strstr Explanation Page 367 strstr can be used to search a string in another string. It s return value is a pointer. If the s2 is found in s1 then the returned pointer points the first occurrence of s2 in s1. If it is not found then it returns a NULL pointer. Example: strstr ( s1, s2 ) If s2 is not included in s1 returns NULL char str1[]= Gaziantep ; /* defining two strings */ char str2[]= az ; /* defining a character variable */ if ( strstr ( str1, str2 )! = NULL ) {printf( %s is found in %s, str2, str1 ); printf( \nreturn Value: %s is found in %s, strstr(str2, str1) ); } else printf( %s is not found in %s, str2, str1 );

44 Function strstr Example Program Page 367 * Output of the Program *

45 Function strtok Explanation Page 368 strtok can be used to tokenize a string into small pieces like words. A token here means the sequence of characters separated by a specific character (delimiters) like space or dash ( ). Example: strtok ( s, c ) If c delimiter found string, it returns the first sequence of the characters found in c. If no more specified character found in s, it returns NULL. char str[]= I live in Gaziantep. ; /* defining a strings */ char *ptr; /* define a character pointer */ ptr = strtok (str, ); /* tokenizing sting ptr becomes I */ if ( ptr! = NULL ) printf ( %s\n, ptr); /* prints I */ ptr = strtok (NULL, ); /* tokenize again ptr becomes live */ if ( ptr! = NULL ) printf ( %s\n, ptr); /* prints live */ This idea can be used to break up a sentence in to words.

46 Function strtok Example Program Page 368 * Output of the Program *

47 Page 369 There are memory functions in C libraries (stdlib.h) that allows programmers to manipulate, compare, and search block of data in the memory. These functions can be used to manipulate, compare, and search string by treating the block of data as a string (objects string arrays). Below table summaries usage and the brief description these functions. Notice that; The pointer parameters (arguments) are defined as void * so they can be used to manipulate any type of data.

48 Function memcpy Explanation Page 370 memcpy can be used to copy a specified number of characters from the second argument to first argument. This does copy the `\0` if it is within the range otherwise only copies and overwrites the indicated n characters. Example: memcpy ( s1, s2, n ) copy n character from s2 to s1. char str1[]= Gaziantep ; /* defining two strings */ char str2[]= 123_A ; /* defining a character variable */ printf( Before str1:%s, str1 ); /* prints Gaziantep */ memcpy ( str1, str2,5); printf( After str1:%s, str1 ); /* prints 123_Antep */

49 Function memcpy Example Program Page 370 * Output of the Program *

50 Function memmove Explanation Page 371 memmove can be used to copy a specified number of characters from the second argument to first argument similar to memcpy. But this memmove can be used to move the data within the same object. Example: memmove ( s1, s2, n ) copy n character from s2 object to s1. char str[]= Call Sweet Home ; /* defining two strings */ printf( Before str:%s, str ); /* Call Sweet Home */ memmove ( str, &str[11],5); /* Copy 5 character from 11 th element */ printf( After str:%s, str ); /* Home Sweet Home */

51 Function memmove Example Program Page 371 memmove ( x, &x[5], 10 ) First arguments x points the x[0] Second argument points the 5 th element ( x[5] is S). Starting from S, it copies 10 element on to the first pointer ( x[0]). * Output of the Program *

52 Function memcmp Explanation Page 371 memcmp can be used to compare a specified number of characters from the second argument with specified number of characters from first argument similar to strcmp. If s1 and s2 are the same then returns 0 If s1 is greater than the s2 then returns 1 If s1 is less than the s2 then returns 1 Example: memcmp ( s1, s2, n ) Compares n characters in s1 and s2 objects. char str1[]= ABC123, str2[]= ABc123 ; /* defining two strings */ printf( Comparing only 2 characters:%d, memcmp(str1, str2, 2 ); /* 0 */ printf( Comparing only 3 characters:%d, memcmp(str1, str2, 3 ); /* 1 */ printf( Comparing only 3 characters:%d, memcmp(str2, str1, 3 ); /* 1 */

53 Function memcmp Example Program Page 371 memcmp ( str1, str2, n ) compares the strings alphabetically for n Characters. 0 : str1 and str2 same for n character. 1 : str1 greater than str2 means it should come after str2 alphabetically. 1 : str1 less than str2 means it should come before str2 alphabetically. * Output of the Program *

54 Function memchr Explanation Page 372 memchr can be used to search for a character in a string. If character c is found then a pointer to first occurrence of the character is returned. If not found then NULL character is returned. Example: memchr ( s, c, n ) Searches n characters in s for c. char str1[]= ABC123, str2[]= ABc123 ; /* defining two strings */ printf( Searching for C:%s, memchr(str1, C, 6 ); /* prints C123 */ printf( Searching for C:%s, memchr(str2, C, 6 ); /* prints null */ printf( Searching for C:%s, memchr(str2, c, 6 ); /* prints c123 */ printf( Searching for C:%s, memchr(str2, c, 2 ); /* prints NULL */ printf( Searching for C:%s, memchr(str2, c, 3 ); /* prints c123 */

55 Function memchr Example Program Page 372 memchr ( s, `r`, 16 ) searches for r in 16 character of s array. Found, so returning pointer will be pointing the `r` in the array. * Output of the Program *

56 Function memset Explanation Page 372 memset can be used to assign/copy/write a character value to specified number of elements in a string array. Example: memset ( s, c, n ) Assign c to n characters in s. char str[]= ABC123 ; /* defining two strings */ memset (str, q, 3); /* it writes q to first three elements > qqq123*/

57 Function memset Example Program Page 372 memset ( s, `b`, 7 ) inserts/assign `b` character to 7 elements in s. Note: Return values is also the string1 after assigning the requested character. * Output of the Program *

58 Page 373 The two remaining functions of this chapter are the sterror and strlen. While running a program, some errors may take place/occur. In order track down the errors in a program. Error codes can be tracked down using errno.h library. Then strerror function can be used to print these error codes in a user friendly format. strlen function determines the length of a string. \0 is not included in the calculated length.

59 Function strerr Example Program Page 373 * Output of the Program *

60 Function strlen Example Program Page 372 strlen ( string1 ) returns the length of the string excluding `\0`. * Output of the Program *

61 Page 370 * Some Outputs of the Program * YOU MAY ALSO USE MEMCMP INSTEAD OF STRCMP

62 Page 372 * Output of the Program *

63 Page 371 * Output of the Program *

64 Page 371 * Output of the Program *

65 Page 371 * Output of the Program *

66 Page 374 * Some Outputs of the Program *

C: How to Program. Week /May/28

C: How to Program. Week /May/28 C: How to Program Week 14 2007/May/28 1 Chapter 8 - Characters and Strings Outline 8.1 Introduction 8.2 Fundamentals of Strings and Characters 8.3 Character Handling Library 8.4 String Conversion Functions

More information

Chapter 8 - Characters and Strings

Chapter 8 - Characters and Strings 1 Chapter 8 - Characters and Strings Outline 8.1 Introduction 8.2 Fundamentals of Strings and Characters 8.3 Character Handling Library 8.4 String Conversion Functions 8.5 Standard Input/Output Library

More information

Characters and Strings

Characters and Strings Characters and Strings 60-141: Introduction to Algorithms and Programming II School of Computer Science Term: Summer 2013 Instructor: Dr. Asish Mukhopadhyay Character constants A character in single quotes,

More information

Fundamentals of Programming. Lecture 11: C Characters and Strings

Fundamentals of Programming. Lecture 11: C Characters and Strings 1 Fundamentals of Programming Lecture 11: C Characters and Strings Instructor: Fatemeh Zamani f_zamani@ce.sharif.edu Sharif University of Technology Computer Engineering Department The lectures of this

More information

by Pearson Education, Inc. All Rights Reserved.

by Pearson Education, Inc. All Rights Reserved. The string-handling library () provides many useful functions for manipulating string data (copying strings and concatenating strings), comparing strings, searching strings for characters and

More information

Scientific Programming in C V. Strings

Scientific Programming in C V. Strings Scientific Programming in C V. Strings Susi Lehtola 1 November 2012 C strings As mentioned before, strings are handled as character arrays in C. String constants are handled as constant arrays. const char

More information

Contents. Preface. Introduction. Introduction to C Programming

Contents. Preface. Introduction. Introduction to C Programming c11fptoc.fm Page vii Saturday, March 23, 2013 4:15 PM Preface xv 1 Introduction 1 1.1 1.2 1.3 1.4 1.5 Introduction The C Programming Language C Standard Library C++ and Other C-Based Languages Typical

More information

C Characters and Strings

C Characters and Strings CS 2060 Character handling The C Standard Library provides many functions for testing characters in ctype.h. int isdigit(int c); // is c a digit (0-9)? int isalpha(int c); // is c a letter? int isalnum(int

More information

Chapter 8: Character & String. In this chapter, you ll learn about;

Chapter 8: Character & String. In this chapter, you ll learn about; Chapter 8: Character & String Principles of Programming In this chapter, you ll learn about; Fundamentals of Strings and Characters The difference between an integer digit and a character digit Character

More information

C mini reference. 5 Binary numbers 12

C mini reference. 5 Binary numbers 12 C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char

More information

Computer Programming

Computer Programming Computer Programming Make everything as simple as possible, but not simpler. Albert Einstein T.U. Cluj-Napoca - Computer Programming - lecture 4 - M. Joldoş 1 Outline Functions Structure of a function

More information

Structured programming

Structured programming Exercises 10 Version 1.0, 13 December, 2016 Table of Contents 1. Strings...................................................................... 1 1.1. Remainders from lectures................................................

More information

C Libraries. Bart Childs Complementary to the text(s)

C Libraries. Bart Childs Complementary to the text(s) C Libraries Bart Childs Complementary to the text(s) 2006 C was designed to make extensive use of a number of libraries. A great reference for student purposes is appendix B of the K&R book. This list

More information

Outline. Computer Programming. Structure of a function. Functions. Function prototype. Structure of a function. Functions

Outline. Computer Programming. Structure of a function. Functions. Function prototype. Structure of a function. Functions Outline Computer Programming Make everything as simple as possible, but not simpler. Albert Einstein Functions Structure of a function Function invocation Parameter passing Functions as parameters Variable

More information

C PROGRAMMING. Characters and Strings File Processing Exercise

C PROGRAMMING. Characters and Strings File Processing Exercise C PROGRAMMING Characters and Strings File Processing Exercise CHARACTERS AND STRINGS A single character defined using the char variable type Character constant is an int value enclosed by single quotes

More information

Introduction to string

Introduction to string 1 Introduction to string String is a sequence of characters enclosed in double quotes. Normally, it is used for storing data like name, address, city etc. ASCII code is internally used to represent string

More information

today cs3157-fall2002-sklar-lect05 1

today cs3157-fall2002-sklar-lect05 1 today homework #1 due on monday sep 23, 6am some miscellaneous topics: logical operators random numbers character handling functions FILE I/O strings arrays pointers cs3157-fall2002-sklar-lect05 1 logical

More information

Appendices E through H are PDF documents posted online at the book s Companion Website (located at

Appendices E through H are PDF documents posted online at the book s Companion Website (located at chtp7_printonlytoc.fm Page vii Monday, January 23, 2012 1:30 PM Appendices E through H are PDF documents posted online at the book s Companion Website (located at www.pearsonhighered.com/deitel). Preface

More information

SWEN-250 Personal SE. Introduction to C

SWEN-250 Personal SE. Introduction to C SWEN-250 Personal SE Introduction to C A Bit of History Developed in the early to mid 70s Dennis Ritchie as a systems programming language. Adopted by Ken Thompson to write Unix on a the PDP-11. At the

More information

Chapter 8 Character Arrays and Strings

Chapter 8 Character Arrays and Strings Chapter 8 Character Arrays and Strings INTRODUCTION A string is a sequence of characters that is treated as a single data item. String constant: String constant example. \ String constant example.\ \ includes

More information

Characters, c-strings, and the string Class. CS 1: Problem Solving & Program Design Using C++

Characters, c-strings, and the string Class. CS 1: Problem Solving & Program Design Using C++ Characters, c-strings, and the string Class CS 1: Problem Solving & Program Design Using C++ Objectives Perform character checks and conversions Knock down the C-string fundamentals Point at pointers and

More information

C Programming. Unit 9. Manipulating Strings File Processing.

C Programming. Unit 9. Manipulating Strings File Processing. Introduction to C Programming Unit 9 Manipulating Strings File Processing skong@itt-tech.edu Unit 8 Review Unit 9: Review of Past Material Unit 8 Review Arrays Collection of adjacent memory cells Each

More information

Strings. Arrays of characters. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY

Strings. Arrays of characters. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY Strings Arrays of characters Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY 1 Basics Strings A string is a sequence of characters treated as a group We have already

More information

Chapter 9 Strings. With this array declaration: char s[10];

Chapter 9 Strings. With this array declaration: char s[10]; Chapter 9 Strings 9.1 Chapter Overview There is no data type in C called ʻstringʼ; instead, strings are represented by an array of characters. There is an assortment of useful functions for strings that

More information

Introduction to Algorithms and Data Structures. Lecture 6 - Stringing Along - Character and String Manipulation

Introduction to Algorithms and Data Structures. Lecture 6 - Stringing Along - Character and String Manipulation Introduction to Algorithms and Data Structures Lecture 6 - Stringing Along - Character and String Manipulation What are Strings? Character data is stored as a numeric code that represents that particular

More information

Strings and Library Functions

Strings and Library Functions Unit 4 String String is an array of character. Strings and Library Functions A string variable is a variable declared as array of character. The general format of declaring string is: char string_name

More information

8. Characters, Strings and Files

8. Characters, Strings and Files REGZ9280: Global Education Short Course - Engineering 8. Characters, Strings and Files Reading: Moffat, Chapter 7, 11 REGZ9280 14s2 8. Characters and Arrays 1 ASCII The ASCII table gives a correspondence

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called.

A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called. Chapter-12 FUNCTIONS Introduction A function is a named group of statements developed to solve a sub-problem and returns a value to other functions when it is called. Types of functions There are two types

More information

ONE DIMENSIONAL ARRAYS

ONE DIMENSIONAL ARRAYS LECTURE 14 ONE DIMENSIONAL ARRAYS Array : An array is a fixed sized sequenced collection of related data items of same data type. In its simplest form an array can be used to represent a list of numbers

More information

Lecture 10 Arrays (2) and Strings. UniMAP SEM II - 11/12 DKT121 1

Lecture 10 Arrays (2) and Strings. UniMAP SEM II - 11/12 DKT121 1 Lecture 10 Arrays (2) and Strings UniMAP SEM II - 11/12 DKT121 1 Outline 8.1 Passing Arrays to Function 8.2 Displaying Array in a Function 8.3 How Arrays are passed in a function call 8.4 Introduction

More information

Muntaser Abulafi Yacoub Sabatin Omar Qaraeen. C Data Types

Muntaser Abulafi Yacoub Sabatin Omar Qaraeen. C Data Types Programming Fundamentals for Engineers 0702113 5. Basic Data Types Muntaser Abulafi Yacoub Sabatin Omar Qaraeen 1 2 C Data Types Variable definition C has a concept of 'data types' which are used to define

More information

System Design and Programming II

System Design and Programming II System Design and Programming II CSCI 194 Section 01 CRN: 10968 Fall 2017 David L. Sylvester, Sr., Assistant Professor Chapter 10 Characters, Strings, and the string Class Character Testing The C++ library

More information

Arrays, Strings, & Pointers

Arrays, Strings, & Pointers Arrays, Strings, & Pointers Alexander Nelson August 31, 2018 University of Arkansas - Department of Computer Science and Computer Engineering Arrays, Strings, & Pointers Arrays, Strings, & Pointers are

More information

Reading Assignment. Strings. K.N. King Chapter 13. K.N. King Sections 23.4, Supplementary reading. Harbison & Steele Chapter 12, 13, 14

Reading Assignment. Strings. K.N. King Chapter 13. K.N. King Sections 23.4, Supplementary reading. Harbison & Steele Chapter 12, 13, 14 Reading Assignment Strings char identifier [ size ] ; char * identifier ; K.N. King Chapter 13 K.N. King Sections 23.4, 23.5 Supplementary reading Harbison & Steele Chapter 12, 13, 14 Strings are ultimately

More information

,$5(0%(''(':25.%(1&+ $16,&'(9(/230(17722/6 EMBEDDED WORKBENCH ANSI C COMPILER C-SPY FOR NATIONAL SEMICONDUCTOR CORP. S &RPSDFW5,6& 70 &5

,$5(0%(''(':25.%(1&+ $16,&'(9(/230(17722/6 EMBEDDED WORKBENCH ANSI C COMPILER C-SPY FOR NATIONAL SEMICONDUCTOR CORP. S &RPSDFW5,6& 70 &5 ,$5(0%(''(':25.%(1&+ $16,&'(9(/230(17722/6 EMBEDDED WORKBENCH Runs under Windows 95, NT and 3.11. Total integration of compiler, assembler, linker and debugger. Plug-in architecture for several IAR toolsets.

More information

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

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are

More information

CSCE150A. Introduction. Basics. String Library. Substrings. Line Scanning. Sorting. Command Line Arguments. Misc CSCE150A. Introduction.

CSCE150A. Introduction. Basics. String Library. Substrings. Line Scanning. Sorting. Command Line Arguments. Misc CSCE150A. Introduction. Chapter 9 Scanning Computer Science & Engineering 150A Problem Solving Using Computers Lecture 07 - Strings Stephen Scott (Adapted from Christopher M. Bourke) Scanning 9.1 String 9.2 Functions: Assignment

More information

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 9. Strings. Notes. Notes. Notes. Lecture 07 - Strings

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 9. Strings. Notes. Notes. Notes. Lecture 07 - Strings Computer Science & Engineering 150A Problem Solving Using Computers Lecture 07 - Strings Scanning Stephen Scott (Adapted from Christopher M. Bourke) 1 / 51 Fall 2009 cbourke@cse.unl.edu Chapter 9 Scanning

More information

Review: Constants. Modules and Interfaces. Modules. Clients, Interfaces, Implementations. Client. Interface. Implementation

Review: Constants. Modules and Interfaces. Modules. Clients, Interfaces, Implementations. Client. Interface. Implementation Review: Constants Modules and s CS 217 C has several ways to define a constant Use #define #define MAX_VALUE 10000 Substitution by preprocessing (will talk about this later) Use const const double x =

More information

Computer Science & Engineering 150A Problem Solving Using Computers

Computer Science & Engineering 150A Problem Solving Using Computers Computer Science & Engineering 150A Problem Solving Using Computers Lecture 07 - Strings Stephen Scott (Adapted from Christopher M. Bourke) 1 / 51 Fall 2009 Chapter 9 9.1 String 9.2 Functions: Assignment

More information

Course organization. Course introduction ( Week 1)

Course organization. Course introduction ( Week 1) Course organization Course introduction ( Week 1) Code editor: Emacs Part I: Introduction to C programming language (Week 2-9) Chapter 1: Overall Introduction (Week 1-3) Chapter 2: Types, operators and

More information

CSE2301. Functions. Functions and Compiler Directives

CSE2301. Functions. Functions and Compiler Directives Warning: These notes are not complete, it is a Skelton that will be modified/add-to in the class. If you want to us them for studying, either attend the class or get the completed notes from someone who

More information

Chapter 10 Characters, Strings, and the string class

Chapter 10 Characters, Strings, and the string class Standard Version of Starting Out with C++, 4th Edition Chapter 10 Characters, Strings, and the string class Copyright 2003 Scott/Jones Publishing Topics 10.1 Character Testing 10.2 Character Case Conversion

More information

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

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions Announcements Thursday Extras: CS Commons on Thursdays @ 4:00 pm but none next week No office hours next week Monday or Tuesday Reflections: when to use if/switch statements for/while statements Floating-point

More information

CS167 Programming Assignment 1: Shell

CS167 Programming Assignment 1: Shell CS167 Programming Assignment 1: Assignment Out: Sep. 5, 2007 Helpsession: Sep. 11, 2007 (8:00 pm, Motorola Room, CIT 165) Assignment Due: Sep. 17, 2007 (11:59 pm) 1 Introduction In this assignment you

More information

N v 1. Type generic string interfaces honor the const contract of application code ISO/IEC JTC 1/SC 22/WG14. August 20, 2016

N v 1. Type generic string interfaces honor the const contract of application code ISO/IEC JTC 1/SC 22/WG14. August 20, 2016 Type generic string interfaces honor the const contract of application code Jens Gustedt INRIA and ICube, Université de Strasbourg, France ISO/IEC JTC 1/SC 22/WG14 August 20, 2016 N 2068 v 1 In several

More information

Section 3: Library Functions

Section 3: Library Functions Section 3: Library Functions This section of the manual describes the functions available to programs from the standard Xinu library. C programmers will recognize some of the C library functions (esp.

More information

Princeton University Computer Science 217: Introduction to Programming Systems. Goals of this Lecture. A Taste of C. Agenda.

Princeton University Computer Science 217: Introduction to Programming Systems. Goals of this Lecture. A Taste of C. Agenda. Princeton University Computer Science 217: Introduction to Programming Systems Goals of this Lecture A Taste of C C Help you learn about: The basics of C Deterministic finite-state automata (DFA) Expectations

More information

Library and function of C. Dr. Donald Davendra Ph.D. (Department of ComputingLibrary Science, andfei function VSB-TU of COstrava)

Library and function of C. Dr. Donald Davendra Ph.D. (Department of ComputingLibrary Science, andfei function VSB-TU of COstrava) Library and function of C Dr. Donald Davendra Ph.D. Department of Computing Science, FEI VSB-TU Ostrava 1 / 30 Description of functions and macros and their standard libraries Macro used for

More information

MC8051: Speichertypen und Adressräume

MC8051: Speichertypen und Adressräume MC8051: Speichertypen und Adressräume FFFF FF FF FFFF code sfr sfr16 sbit Special Function Registers 80 data/ idata idata interner Datenspeicher 7F 80 xdata Speichertyp Adresse Speicherbereiche data 00-7F

More information

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University

Main Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types

More information

Iosif Ignat, Marius Joldoș Laboratory Guide 9. Character strings CHARACTER STRINGS

Iosif Ignat, Marius Joldoș Laboratory Guide 9. Character strings CHARACTER STRINGS CHARACTER STRINGS 1. Overview The learning objective of this lab session is to: Understand the internal representation of character strings Acquire skills in manipulating character strings with standard

More information

CROSSWARE C8051NT ANSI C Compiler for Windows

CROSSWARE C8051NT ANSI C Compiler for Windows CROSSWARE C8051NT 7 The Crossware C8051NT is a sophisticated ANSI standard C compiler that generates code for the 8051 family of microcontrollers. It provides numerous extensions that allow access to 8051

More information

Goals of this Lecture

Goals of this Lecture A Taste of C C 1 Goals of this Lecture Help you learn about: The basics of C Deterministic finite state automata (DFA) Expectations for programming assignments Why? Help you get started with Assignment

More information

Chapter 10: Characters, C- Strings, and More About the string Class

Chapter 10: Characters, C- Strings, and More About the string Class Chapter 10: Characters, C- Strings, and More About the string Class 10.1 Character Testing Character Testing require cctype header file FUNCTION isalpha isalnum isdigit islower isprint ispunct isupper

More information

Chapter 10: Character Testing. From Program Character Case Conversion 8/23/2014. Character Testing. Character Case Conversion

Chapter 10: Character Testing. From Program Character Case Conversion 8/23/2014. Character Testing. Character Case Conversion Chapter 10: Characters, C- Strings, and More About the string Class 10.1 Character Testing Character Testing Requires cctype header file From Program 10-1 FUNCTION isalpha isalnum isdigit islower isprint

More information

CS 137 Part 6. ASCII, Characters, Strings and Unicode. November 3rd, 2017

CS 137 Part 6. ASCII, Characters, Strings and Unicode. November 3rd, 2017 CS 137 Part 6 ASCII, Characters, Strings and Unicode November 3rd, 2017 Characters Syntax char c; We ve already seen this briefly earlier in the term. In C, this is an 8-bit integer. The integer can be

More information

Computer Security. Robust and secure programming in C. Marius Minea. 12 October 2017

Computer Security. Robust and secure programming in C. Marius Minea. 12 October 2017 Computer Security Robust and secure programming in C Marius Minea marius@cs.upt.ro 12 October 2017 In this lecture Write correct code minimizing risks with proper error handling avoiding security pitfalls

More information

C strings. (Reek, Ch. 9) 1 CS 3090: Safety Critical Programming in C

C strings. (Reek, Ch. 9) 1 CS 3090: Safety Critical Programming in C C strings (Reek, Ch. 9) 1 Review of strings Sequence of zero or more characters, terminated by NUL (literally, the integer value 0) NUL terminates a string, but isn t part of it important for strlen()

More information

1 Pointer Concepts. 1.1 Pointer Examples

1 Pointer Concepts. 1.1 Pointer Examples 1 1 Pointer Concepts What are pointers? How are they used? Point to a memory location. Call by reference is based on pointers. Operators: & Address operator * Dereferencing operator Machine/compiler dependencies

More information

Chapter 10: Characters, C- Strings, and More About the string Class Character Testing

Chapter 10: Characters, C- Strings, and More About the string Class Character Testing Chapter 10: Characters, C- Strings, and More About the string Class 1 10.1 Character Testing 2 Character Testing require cctype header file FUNCTION isalpha isalnum isdigit islower isprint ispunct isupper

More information

Princeton University Computer Science 217: Introduction to Programming Systems. A Taste of C

Princeton University Computer Science 217: Introduction to Programming Systems. A Taste of C Princeton University Computer Science 217: Introduction to Programming Systems A Taste of C C 1 Goals of this Lecture Help you learn about: The basics of C Deterministic finite-state automata (DFA) Expectations

More information

Overview. Concepts this lecture String constants Null-terminated array representation String library <strlib.h> String initializers Arrays of strings

Overview. Concepts this lecture String constants Null-terminated array representation String library <strlib.h> String initializers Arrays of strings CPE 101 slides based on UW course Lecture 19: Strings Overview Concepts this lecture String constants ull-terminated array representation String library String initializers Arrays of strings

More information

Appendix A Developing a C Program on the UNIX system

Appendix A Developing a C Program on the UNIX system Appendix A Developing a C Program on the UNIX system 1. Key in and save the program using vi - see Appendix B - (or some other editor) - ensure that you give the program file a name ending with.c - to

More information

Announcements. Strings and Pointers. Strings. Initializing Strings. Character I/O. Lab 4. Quiz. July 18, Special character arrays

Announcements. Strings and Pointers. Strings. Initializing Strings. Character I/O. Lab 4. Quiz. July 18, Special character arrays Strings and Pointers Announcements Lab 4 Why are you taking this course? Lab 5 #, 8: Reading in data from file using fscanf Quiz Quiz Strings Special character arrays End in null character, \ char hi[6];

More information

Introduction C CC. Advanced C

Introduction C CC. Advanced C Introduction C C CC Advanced C i ii Advanced C C CIntroduction CC C CC Advanced C Peter D. Hipson A Division of Prentice Hall Computer Publishing 201 W. 103rd St., Indianapolis, Indiana 46290 USA iii Advanced

More information

Basic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Announcements Exam 1 (20%): Feb. 27 (Tuesday) Tentative Proposal Deadline:

More information

Converting a Lowercase Letter Character to Uppercase (Or Vice Versa)

Converting a Lowercase Letter Character to Uppercase (Or Vice Versa) Looping Forward Through the Characters of a C String A lot of C string algorithms require looping forward through all of the characters of the string. We can use a for loop to do that. The first character

More information

UNIT-I Input/ Output functions and other library functions

UNIT-I Input/ Output functions and other library functions Input and Output functions UNIT-I Input/ Output functions and other library functions All the input/output operations are carried out through function calls. There exists several functions that become

More information

Computers Programming Course 11. Iulian Năstac

Computers Programming Course 11. Iulian Năstac Computers Programming Course 11 Iulian Năstac Recap from previous course Cap. Matrices (Arrays) Matrix representation is a method used by a computer language to store matrices of different dimension in

More information

mith College Computer Science CSC270 Spring 2016 Circuits and Systems Lecture Notes, Week 11 Dominique Thiébaut

mith College Computer Science CSC270 Spring 2016 Circuits and Systems Lecture Notes, Week 11 Dominique Thiébaut mith College Computer Science CSC270 Spring 2016 Circuits and Systems Lecture Notes, Week 11 Dominique Thiébaut dthiebaut@smithedu Outline A Few Words about HW 8 Finish the Input Port Lab! Revisiting Homework

More information

Introduction to Programming Systems

Introduction to Programming Systems Introduction to Programming Systems CS 217 Thomas Funkhouser & Bob Dondero Princeton University Goals Master the art of programming Learn how to be good programmers Introduction to software engineering

More information

Lecture 05 Pointers ctd..

Lecture 05 Pointers ctd.. Lecture 05 Pointers ctd.. Note: some notes here are the same as ones in lecture 04 1 Introduction A pointer is an address in the memory. One of the unique advantages of using C is that it provides direct

More information

Multiple Choice Questions ( 1 mark)

Multiple Choice Questions ( 1 mark) Multiple Choice Questions ( 1 mark) Unit-1 1. is a step by step approach to solve any problem.. a) Process b) Programming Language c) Algorithm d) Compiler 2. The process of walking through a program s

More information

LESSON 4. The DATA TYPE char

LESSON 4. The DATA TYPE char LESSON 4 This lesson introduces some of the basic ideas involved in character processing. The lesson discusses how characters are stored and manipulated by the C language, how characters can be treated

More information

Strings. Daily Puzzle

Strings. Daily Puzzle Lecture 20 Strings Daily Puzzle German mathematician Gauss (1777-1855) was nine when he was asked to add all the integers from 1 to 100 = (1+100)+(2+99)+... = 5050. Sum all the digits in the integers from

More information

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3).

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3). cs3157: another C lecture (mon-21-feb-2005) C pre-processor (1). today: C pre-processor command-line arguments more on data types and operators: booleans in C logical and bitwise operators type conversion

More information

CS 261 Fall Mike Lam, Professor. Structs and I/O

CS 261 Fall Mike Lam, Professor. Structs and I/O CS 261 Fall 2018 Mike Lam, Professor Structs and I/O Typedefs A typedef is a way to create a new type name Basically a synonym for another type Useful for shortening long types or providing more meaningful

More information

Strings. Chuan-Ming Liu. Computer Science & Information Engineering National Taipei University of Technology Taiwan

Strings. Chuan-Ming Liu. Computer Science & Information Engineering National Taipei University of Technology Taiwan Strings Chuan-Ming Liu Computer Science & Information Engineering National Taipei University of Technology Taiwan 1 Outline String Basic String Library Functions Longer Strings: Concatenation and Whole-Line

More information

Standard C Library Functions

Standard C Library Functions Demo lecture slides Although I will not usually give slides for demo lectures, the first two demo lectures involve practice with things which you should really know from G51PRG Since I covered much of

More information

String Class in C++ When the above code is compiled and executed, it produces result something as follows: cin and strings

String Class in C++ When the above code is compiled and executed, it produces result something as follows: cin and strings String Class in C++ The standard C++ library provides a string class type that supports all the operations mentioned above, additionally much more functionality. We will study this class in C++ Standard

More information

AVR Development Tools

AVR Development Tools Development Tools AVR Development Tools This section describes some of the development tools that are available for the 8-bit AVR family. ATMEL AVR Assembler ATMEL AVR Simulator IAR ANSI C-Compiler, Assembler,

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features

More information

Split up Syllabus (Session )

Split up Syllabus (Session ) Split up Syllabus (Session- -17) COMPUTER SCIENCE (083) CLASS XI Unit No. Unit Name Marks 1 COMPUTER FUNDAMENTALS 10 2 PROGRAMMING METHODOLOGY 12 3 INTRODUCTION TO C++ 14 4 PROGRAMMING IN C++ 34 Total

More information

CS3157: Advanced Programming. Outline

CS3157: Advanced Programming. Outline CS3157: Advanced Programming Lecture #8 Feb 27 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline More c Preprocessor Bitwise operations Character handling Math/random Review for midterm Reading: k&r ch

More information

Characters in C consist of any printable or nonprintable character in the computer s character set including lowercase letters, uppercase letters,

Characters in C consist of any printable or nonprintable character in the computer s character set including lowercase letters, uppercase letters, Strings Characters in C consist of any printable or nonprintable character in the computer s character set including lowercase letters, uppercase letters, decimal digits, special characters and escape

More information

C Programming Multiple. Choice

C Programming Multiple. Choice C Programming Multiple Choice Questions 1.) Developer of C language is. a.) Dennis Richie c.) Bill Gates b.) Ken Thompson d.) Peter Norton 2.) C language developed in. a.) 1970 c.) 1976 b.) 1972 d.) 1980

More information

CMPSC 311- Introduction to Systems Programming Module: Strings

CMPSC 311- Introduction to Systems Programming Module: Strings CMPSC 311- Introduction to Systems Programming Module: Strings Professor Patrick McDaniel Fall 2014 A string is just an array... C handles ASCII text through strings A string is just an array of characters

More information

o Echo the input directly to the output o Put all lower-case letters in upper case o Put the first letter of each word in upper case

o Echo the input directly to the output o Put all lower-case letters in upper case o Put the first letter of each word in upper case Overview of Today s Lecture Lecture 2: Character Input/Output in C Prof. David August COS 217 http://www.cs.princeton.edu/courses/archive/fall07/cos217/ Goals of the lecture o Important C constructs Program

More information

Using Character Arrays. What is a String? Using Character Arrays. Using Strings Life is simpler with strings. #include <stdio.

Using Character Arrays. What is a String? Using Character Arrays. Using Strings Life is simpler with strings. #include <stdio. What is a String? A string is actually a character array. You can use it like a regular array of characters. However, it has also some unique features that make string processing easy. Using Character

More information

LECTURE 15. String I/O and cstring library

LECTURE 15. String I/O and cstring library LECTURE 15 String I/O and cstring library RECAP Recall that a C-style string is a character array that ends with the null character. Character literals in single quotes: 'a', '\n', '$ String literals in

More information

Approximately a Test II CPSC 206

Approximately a Test II CPSC 206 Approximately a Test II CPSC 206 Sometime in history based on Kelly and Pohl Last name, First Name Last 5 digits of ID Write your section number(s): All parts of this exam are required unless plainly and

More information

ARRAYS(II Unit Part II)

ARRAYS(II Unit Part II) ARRAYS(II Unit Part II) Array: An array is a collection of two or more adjacent cells of similar type. Each cell in an array is called as array element. Each array should be identified with a meaningful

More information

Vidyalankar. F.E. Sem. II Structured Programming Approach Prelim Question Paper Solution

Vidyalankar. F.E. Sem. II Structured Programming Approach Prelim Question Paper Solution 1. (a) 1. (b) 1. (c) F.E. Sem. II Structured Programming Approach C provides a variety of stroage class specifiers that can be used to declare explicitly the scope and lifetime of variables. The concepts

More information

LAB7 : Characters and Strings

LAB7 : Characters and Strings 1 LAB7 : Characters and Strings Task1: Write a C Program to Copy One String into Other Without Using Library Function. (use pointer) char s1[100], s2[100]; printf("\nenter the string :"); gets(s1); i =

More information

Reminder. Sign up for ee209 mailing list. Precept. If you haven t received any from ee209 yet Follow the link from our class homepage

Reminder. Sign up for ee209 mailing list. Precept. If you haven t received any  from ee209 yet Follow the link from our class homepage EE209: C Examples 1 Reminder Sign up for ee209 mailing list If you haven t received any email from ee209 yet Follow the link from our class homepage Precept 7:00-8:15pm, every Wednesday 창의학습관 (Creative

More information

A First Book of ANSI C Fourth Edition. Chapter 9 Character Strings

A First Book of ANSI C Fourth Edition. Chapter 9 Character Strings A First Book of ANSI C Fourth Edition Chapter 9 Character Strings Objectives String Fundamentals Library Functions Input Data Validation Formatting Strings (Optional) Case Study: Character and Word Counting

More information

AIR FORCE SCHOOL,BAMRAULI COMPUTER SCIENCE (083) CLASS XI Split up Syllabus (Session ) Contents

AIR FORCE SCHOOL,BAMRAULI COMPUTER SCIENCE (083) CLASS XI Split up Syllabus (Session ) Contents AIR FORCE SCHOOL,BAMRAULI COMPUTER SCIENCE (083) CLASS XI Split up Syllabus (Session- 2017-18) Month July Contents UNIT 1: COMPUTER FUNDAMENTALS Evolution of computers; Basics of computer and its operation;

More information

Input / Output Functions

Input / Output Functions CSE 2421: Systems I Low-Level Programming and Computer Organization Input / Output Functions Presentation G Read/Study: Reek Chapter 15 Gojko Babić 10-03-2018 Input and Output Functions The stdio.h contain

More information