DEPARTMENT OF COMPUTER SCIENCE & APPLICATION

Slides:



Advertisements
Similar presentations
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.
Advertisements

Character String Manipulation. Overview Character string functions sscanf() function sprintf() function.
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.
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.
1 Introduction to Computing: Lecture 16 Character Strings Dr. Bekir KARLIK Yasar University Department of Computer Engineering
Searching and Sorting an Array 4 Searching and sorting are two fundamental algorithms often implemented with arrays –Search an array to determine the location.
1 Introduction to Computing Lecture 11 Character Strings Assist.Prof.Dr. Nükhet ÖZBEK Ege University Department of Electrical&Electronics Engineering
N-1 University of Washington Computer Programming I Lecture 19: Strings © 2000 UW CSE.
To remind us We finished the last day by introducing If statements Their structure was:::::::::
Strings A special kind of array is an array of characters ending in the null character \0 called string arrays A string is declared as an array of characters.
CS Nov 2006 C-strings.
1 CSE1301 Computer Programming: Lecture 19 Character Strings.
PRESENTED BY: ER. SUMANPREET KAUR LECTURER IN CE DEPTT. GPCG ASR.
Chapter 9 Character Strings 9.1 Character String Constants A character string constant is a sequence of characters enclosed in double quotation mark. Examples.
Strings Programming Applications. Strings in C C stores a string in a block of memory. The string is terminated by the \0 character:
13. Strings. String Literals String literals are enclosed in double quotes: "Put a disk in drive A, then press any key to continue\n“ A string literal.
5.6 String Processing Part 2. Sprintf(destnvar,…..regularprintf) Write formatted data to string Same as printf except the output is put in variable. A.
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.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
1 Arrays and Pointers The name of an array is a pointer constant to the first element. Because the array’s name is a pointer constant, its value cannot.
Strings. String Literals String literals are enclosed in double quotes: "Put a disk in drive A, then press any key to continue\n“ A string literal may.
13. Strings. String Literals String literals are enclosed in double quotes: "Put a disk in drive A, then press any key to continue\n“ A string literal.
MULTI-DIMENSION ARRAY STRING Computer Programming Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
1 Chapter 8 – Character Arrays and Strings Outline 8.1Introduction 8.2Declaring and Initializing String 8.3Input/output of strings 8.4String-handling Functions.
EC-111 Algorithms & Computing Lecture #10 Instructor: Jahan Zeb Department of Computer Engineering (DCE) College of E&ME NUST.
מערכים (arrays) 02 אוקטובר אוקטובר אוקטובר 1602 אוקטובר אוקטובר אוקטובר 1602 אוקטובר אוקטובר אוקטובר 16 Department.
Computer Organization and Design Pointers, Arrays and Strings in C
C ARRAYS.
Chapter 8 “Character Arrays and Strings” Prepared by: Prof. Ajay M. Patel CE, IDS, NU.
INC 161 , CPE 100 Computer Programming
Fundamentals of Characters and Strings
presented BY : DURGESH KKHANDEKAR 1st semester
Lecture 8 String 1. Concept of strings String and pointers
Programming Languages and Paradigms
Lecture-5 Arrays.
CSE 303 Concepts and Tools for Software Development
Programming Paradigms
Module 2 Arrays and strings – example programs.
Strings A string is a sequence of characters treated as a group
Arrays in C.
Programming Languages and Paradigms
Character Strings Lesson Outline
CSCI206 - Computer Organization & Programming
CS111 Computer Programming
Object Oriented Programming COP3330 / CGS5409
Lecture 8b: Strings BJ Furman 15OCT2012.
C Stuff CS 2308.
CSI 121 Structured Programming Language Lecture 21 Character Strings
CSE1320 Strings Dr. Sajib Datta
INC 161 , CPE 100 Computer Programming
Strings A collection of characters taken as a set:
Lecture 11 Strings.
Strings Dr. Soha S. Zaghloul updated by Rasha ALEidan
EECE.2160 ECE Application Programming
Strings What is a string? It is an array of characters terminated with
Chapter 8 Character Arrays and Strings
CPS120: Introduction to Computer Science
Example: ? str1 str2 _ void salin(char sasaran[], char sumber[]);
ECE 103 Engineering Programming Chapter 25 C Strings, Part 1
String manipulation string.h library
Strings Adapted from Dr. Mary Eberlein, UT Austin.
Strings in C Array of characters is called a string.
Lecture 19: Working with strings
Character Arrays char string1[] = “first”;
Strings #include <stdio.h>
Characters and Strings Functions
Strings Adapted from Dr. Mary Eberlein, UT Austin.
C Characters and Strings
Introduction to Problem Solving and Programming
Presentation transcript:

DEPARTMENT OF COMPUTER SCIENCE & APPLICATION BILASPUR UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE & APPLICATION TOPIC :- STRINGS GUIDED BY:- PRESENTED BY:- Mr.Jitendra kumar Ritu singh

Strings A special kind of array is an array of characters ending in the null character \0 called string arrays A string is declared as an array of characters char s[10] char p[30] When declaring a string don’t forget to leave a space for the null character which is also known as the string terminator character

Standard library string function strcpy - copy one string into another. strcat - append one string onto the right side of the other. strrev – reverses string.

strcpy strcpy(destinationstring, sourcestring) Copies sourcestring into destinationstring For example strcpy(str, “hello world”); assigns “hello world” to the string str

strcpy example #include <stdio.h> #include <string.h> Int main() { Char source[ ] = “RITU”; Char target [10]; Strcpy( target , source); Printf(“source string = %s\n”,source); Printf(“target string = %s\n”,target); Return 0; }

Usre difine function #include<stdio.h> #include<conio.h> Char mystrcpy( char *t, char *s) { While(*s != ‘\0’) *t = *s; s++; t++; } Return *t ; Void main() Char source [ ] = “ ram “ ; Char target [ 6 ] ; mystrcpy( target , source ); Printf(“\n source string = %s ,\n target string = %s “, source,target); Out put :-= source string = ram target string = ram

strcat strcat(destinationstring, sourcestring) appends sourcestring to right hand side of destinationstring For example if str had value “a big ” strcat(str, “hello world”); appends “hello world” to the string “a big ” to get “ a big hello world”

Library function #include <stdio.h> #include <string.h> void main() { Char source [ ] = “ RITU”; Char target [10] = “SINGH”; Strcat ( target,source); Printf (“ source string = %s\n”,source); printf(“target string = %s\n”,target); } Out put :- source string =RITU target string = SINGHRITU

#include<stdio.h> #include<conio.h> char mystrcat( char *t, char *s) { While( *t != ‘\0’) t++; } While(*s!=‘\0’) *t = * s ; s++; target =‘\0’; return target ; void main() str1[ ] = “ hello”; Str2 [ 10] =“simple”; mystrcat(str1,str2); Printf(“ %s %s “, str1,str2);

THANK YOU