Difference between revisions of "C-and-C++/C3/String-Library-Functions/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 1: Line 1:
{| border=1
+
{| border = 1
|| ''Time'''
+
 
|| '''Narration'''
+
|'''Time'''
 +
 
 +
|'''Narration'''
 +
 
  
 
|-
 
|-
| 00:02
+
| 00.01
| Welcome to the spoken-tutorial on String Library Functions in C
+
|Welcome to the spoken-tutorial on String Library Functions in C  
 +
 
  
 
|-
 
|-
| 00:07
+
| 00.07
| In this tutorial, we will learn,
+
|In this tutorial we will learn,  
  
 
|-
 
|-
| 00:10
+
| 00.09
| String Library Functions  
+
|String Library Functions  
  
 
|-
 
|-
| 00:12
+
| 00.11
| We will do this with the help of some examples  
+
|We will do this with the help of some examples  
  
 
|-
 
|-
| 00:15
+
| 00.15
| To record this tutorial, I am using
+
|To record this tutorial, I am using  
  
 
|-
 
|-
| 00:18
+
| 00.18
 
| Ubuntu Operating System version 11.10,  
 
| Ubuntu Operating System version 11.10,  
  
 
|-
 
|-
| 00:23
+
| 00.22
| gcc Compiler Version 4.6.1
+
|gcc Compiler Version 4.6.1  
  
 
|-
 
|-
| 00:27
+
| 00.27
| Let us start with an introduction to string library functions.
+
|Let us start with an introduction to string library functions.  
  
 
|-
 
|-
| 00:31
+
| 00.31
| These are the group of functions implementing operations on strings.
+
|These are the group of functions implementing operations on strings.  
  
 
|-
 
|-
| 00:37
+
|00.36
| Various operations such as copying, concatenation, searching etc are supported.
+
|Various operations such as copying, concatenation, searching etc are supported.
  
 
|-
 
|-
| 00:45
+
|00.44
|Let us see some of the string library functions
+
|Let us see some of the string library functions  
  
 
|-
 
|-
| 00:49
+
|00.48
| Here we have the '''strncpy''' function  
+
|Here we have the strncpy function  
  
 
|-
 
|-
| 00:52
+
|00.52
| The syntax for this is strncpy(char str1, char str2, int n )
+
|The syntax for this is strncpy(char str1, char str2, and int n )  
  
 
|-
 
|-
| 01:02
+
|01.02
| It copies first n characters of '''string str2''' into '''string str1'''.
+
|It copies first n characters of string str2 into string str1
  
 
|-
 
|-
| 01:10
+
| 01.09
| eg. char strncpy(char hello, char world, 2);
+
|example, char strncpy( char hello, char world, 2)
  
 
|-
 
|-
| 01:17
+
| 01.16
| The output will be ;'''Wollo'''
+
|The output will be Wollo  
  
 
|-
 
|-
| 01:21
+
|01.21
| Here we have''' Wo '''fromt the string 2 and rest of the characters from string 1
+
|Here we have Wo from the string 2 and rest of the characters from string 1  
  
 
|-
 
|-
| 01:29
+
| 01.29
| Now we will see strncmp function, the syntax for this is strncmp (char str1, char str2 and int n)
+
|Now we will see strncmp function, the syntax for this is strncmp(char str1, char str2, and int n)
  
 
|-
 
|-
| 01:43
+
| 01.42
| It will compare first n characters of string 2 with string 1
+
|It will compare first n characters of string 2 with string 1  
  
 
|-
 
|-
| 01:49
+
| 01.48
| eg. int strncmp(char ice, char icecream, 2);
+
|example int strncmp(char ice, char icecream, and  2);  
  
 
|-
 
|-
| 01:56
+
|01.55
| The output will be 0
+
|The output will be 0  
  
 
|-
 
|-
| 01:58
+
| 01.58
| Now we will see how to use the string library functions.
+
|Now we will see how to use the string library functions.  
  
 
|-
 
|-
| 02:03
+
| 02.02
| I am going to show you some of the commonly used string functions.
+
|I am going to show you some of the commonly used string functions.  
  
 
|-
 
|-
| 02:08
+
|02.07
| I have already typed the program on the editor,
+
|I have already typed the program on the editor,  
  
 
|-
 
|-
| 02:11
+
|02.10
| i will open it  
+
| I will open it  
  
 
|-
 
|-
| 02:12
+
|02.12
| Here we have the string length function  
+
|Here we have the string length function  
  
 
|-
 
|-
| 02:15
+
|02.15
|   Note that our filename is strlen.c.
+
|Note that our filename is strlen.c.  
  
 
|-
 
|-
| 02:20
+
|02.20
| In this we will find the length of the string  
+
|In this we will find the length of the string  
  
 
|-
 
|-
| 02:24
+
|02.23
| These are the header files as '''stdio.h and string.h '''
+
|These are the header files as stdio.h and string.h.
 +
 
 
|-
 
|-
| 02:29
+
|02.29
| This is our main function
+
|This is our main function  
  
 
|-
 
|-
| 02:32
+
| 02.31
| Here we have a character variable ''''arr'''',
+
|Here we have a character variable 'arr',  
  
 
|-
 
|-
| 02:36
+
| 02.35
| It stores a value ''''Ashwini''''
+
|It stores a value 'Ashwini'
  
 
|-
 
|-
| 02:39
+
| 02.38
| Then we have an integer variable '''len1 '''
+
|Then we have an integer variable len1  
  
 +
|-
 +
| 02.42
 +
|Here we will find the lenght of the string using strlen funtion
  
 +
|-
 +
| 02.48
 +
|The result will be stored in len1
  
 +
|-
 +
| 02.52
 +
|Then we print the string and the length of the string.
  
 
|-
 
|-
| 02:43
+
|02.56
| here we will find the lenght of the string using''' strlen''' funtion
+
|And this is our return statement
  
 
|-
 
|-
| 02:49
+
|02.59
|the result will be stored in '''len1'''
+
|Now let us execute the program
  
 
|-
 
|-
| 02:53
+
|03.01
| Then we print the string and the length of the string.
+
|Open the terminal window by pressing
 +
 
  
 
|-
 
|-
| 02:57
+
| 03.04
|And this is our return statement
+
|Ctrl, Alt and T keys simultaneously on your keyboard
  
 +
|-
 +
| 03.09
 +
| To compile Type: "gcc" space "strlen.c" space “-o” space “str1”. Press Enter
  
 
|-
 
|-
| 02:59
+
| 03.19
|Now let us execute the program
+
|Type (dot slash) ./str1. Press Enter
  
 
|-
 
|-
| 03:02
+
| 03.24
|Open the terminal window by pressing
+
|The output is displayed as
 +
 
 +
|-
 +
| 03.26
 +
|string = Ashwini, Length = 7
 +
 
 +
|-
 +
|03.30
 +
|You can count here. 1,2,3,4,5,6, and 7
 +
 
 +
|-
 +
| 03.37
 +
| Let us see another string function
 +
 
 +
|-
 +
| 03.40
 +
|Here we have the string copy fuction 
 +
 
 +
|-
 +
| 03.43
 +
|Note that our filename is strcpy.c
 +
 
 +
|-
 +
| 03.48
 +
|In this we will copy the source string into the target string
 +
 
 +
|-
 +
| 03.53
 +
|Here we have Ice in the source string, it will be copied to the target string
 +
 
 +
|-
 +
| 03.59
 +
|This is our strcpy function
 +
 
 +
|-
 +
| 04.02
 +
|Here we will print the source string and the target string
 +
 
 +
|-
 +
| 04.07
 +
|Let us execute and see 
 +
 
 +
|-
 +
| 04.09
 +
|Come back to our terminal  
 +
 
 +
|-
 +
| 04.11
 +
| To compile type gcc space strcpy.c space hyphen o space str2. Press Enter
 +
 
 +
 
 +
|-
 +
| 04.20
 +
|Type (dot slash)./str2 Press Enter
 +
 
 +
|-
 +
| 04.24
 +
|The output is displayed as
 +
 
 +
|-
 +
| 04.26
 +
|source string = Ice
 +
 
 +
|-
 +
| 04.29
 +
|target string = Ice
 +
 
 +
|-
 +
| 04.32
 +
| Now let us see another string function
 +
 
 +
|-
 +
| 04.34
 +
|Now we will see the string compare function
 +
 
 +
|-
 +
| 04.37
 +
|Note that our filename is strcmp.c
 +
 
 +
|-
 +
| 04.42
 +
|In this we will comapre two strings
 +
 
 +
|-
 +
| 04.46
 +
|Here we have character variables as str1 and str2 
 +
 
 +
|-
 +
| 04.52
 +
|str1 stores the value as 'Ice' and str2 stores the value as 'Cream'.
 +
 
 +
|-
 +
| 04.58
 +
|Here we have interger variables as i and j
 +
 
 +
|-
 +
| 05.03
 +
|In this we will compare the string using the strcmp function
 +
 
 +
|-
 +
| 05.08
 +
|Here we compare str1 ie: 'Ice' with 'Hello'
 +
 
 +
|-
 +
| 05.14
 +
|The result is stored in i
 +
 
 +
|-
 +
| 05.16
 +
|In this we will compare string2 ie: 'Cream' with 'Cream'
 +
 
 +
|-
 +
| 05.23
 +
|The result is stored in j
 +
 
 +
|-
 +
| 05.25
 +
|Then we print both the results
 +
 
 +
|-
 +
| 05.28
 +
|And this is our return statement
  
 
|-
 
|-
| 03:04
+
| 05.31
|'''Ctrl, Alt''' and '''T''' keys simultaneously on your keyboard
+
|Let us execute the program.
  
 
|-
 
|-
| 03:10
+
| 05.33
To compile
+
|Come back to our terminal.  
  
 
|-
 
|-
| 03:11
+
| 05.35
|Type:  "gcc" space "strlen.c" space “-o” space “str1”.
+
|To compile type gcc space strcmp.c space hyphen o space str3
  
 
|-
 
|-
| 03:19
+
| 05.46
 
|Press Enter
 
|Press Enter
  
 
|-
 
|-
| 03:20
+
| 05.47
|   type: '''./str1'''
+
|Type (dot slash)./str3
  
 
|-
 
|-
| 03:23
+
| 05.50
|Press Enter
+
|The outpur is displayed as 1,0
  
 
|-
 
|-
| 03:24
+
| 05.54
| The output is displayed as
+
|Come back to our program
  
 
|-
 
|-
| 03:26
+
| 05.56
|'''string = Ashwini, Length = 7'''
+
|Here we get 1 and here we get as 0
  
 
|-
 
|-
| 03:30
+
| 06.01
|You can count here. 1,2,3,4,5,6, and 7
+
|Let us come back to our slides
  
 
|-
 
|-
| 03:38
+
| 06.04
|   Let us see another string function
+
|Let us summarize,
  
 
|-
 
|-
| 03:41
+
| 06.06
|Here we have the string copy fuction
+
|In this tutorial we learned,
 +
 
  
 
|-
 
|-
| 03:43
+
| 06.07
|   Note that our filename is '''strcpy.c'''.
+
|String library functions
  
 
|-
 
|-
| 03:49
+
| 06.09
| In this we will copy the source string into the target string
+
|strlen()
  
 
|-
 
|-
| 03:54
+
| 06.11
|Here we have Ice in the source string, it will be copied to the target string .
+
|strcpy()
  
 
|-
 
|-
| 04:00
+
| 06.13
| This is our '''strcpy ''' function
+
|strcmp()
 +
 
  
 
|-
 
|-
| 04:03
+
| 06.14
|   Here we print the source string and the target string
+
|strncpy()
  
 
|-
 
|-
| 04:07
+
| 06.16
| Let us execute and see
+
|and strncmp()
  
 
|-
 
|-
| 04:09
+
| 06.19
|Come back to our terminal
+
|As an assignemnt,
  
 
|-
 
|-
| 04:11
+
| 06.21
| | To compile type
+
|Write a C Program to concatenate String best and String bus.
  
 
|-
 
|-
| 04:12
+
| 06.25
|'''gcc''' space '''strcpy.c '''space '''-o '''space '''str2'''
+
|Hint: strcat(char str1, char str2);
  
 
|-
 
|-
| 04:19
+
| 06.32
|Press '''Enter'''
+
|Also explore the other functions in string library.
  
 
|-
 
|-
| 04:21
+
| 06.36
|Type  '''./str2 '''
+
|Watch the video available at the link shown below
  
 
|-
 
|-
| 04:23
+
| 06.39
|Press''' Enter'''
+
|It summarizes the Spoken Tutorial project
  
+
|-
 +
| 06.42
 +
|If you do not have good bandwidth, you can download and watch it
  
+
|-
 +
| 06.46
 +
|The Spoken Tutorial Project Team
  
 
|-
 
|-
| 04:25
+
| 06.49
| The output is displayed as
+
|Conducts workshops using spoken tutorials
  
 
|-
 
|-
| 04:27
+
| 06.52
|source string = Ice
+
|Gives certificates to those who pass an online test
  
 
|-
 
|-
| 04:30
+
| 06.56
|target string = Ice
+
|For more details, please write to, contact@spoken-tutorial.org
 +
 
  
 
|-
 
|-
| 04:32
+
|07.03
| Now let us see another string function
+
|Spoken Tutorial Project is a part of the Talk to a Teacher project
  
 
|-
 
|-
| 04:35
+
| 07.08
|   Now we will see the string compare function
+
|It is supported by the National Mission on Education through ICT, MHRD, Government of India
  
 
|-
 
|-
| 04:38
+
| 07.15
|Note that our filename is '''strcmp.c'''
+
|More information on this Mission is available at the link shown below
  
 
|-
 
|-
| 04:43
+
| 07.20
|In this we will comapre two strings
+
|This is Ashwini Patil  from IIT Bombay signing of.
  
 
|-
 
|-
| 04:47
+
| 07.24
|Here we have character variables as '''str1''' and '''str2 '''
+
|Thank you for joining. {| border = 1
'
+
 
 +
|'''Time'''
 +
 
 +
|'''Narration'''
 +
 
 +
 
 
|-
 
|-
|   04:53
+
| 00.01
| '''str 1''' stores the value as ''''Ice'''' and    ''' str2 '''stores the value as ''''Cream'.'''
+
|Welcome to the spoken-tutorial on String Library Functions in C
 +
 
  
 
|-
 
|-
| 04:59
+
| 00.07
|Here we have interger variables as''' i '''and''' j'''
+
|In this tutorial we will learn, 
  
 
|-
 
|-
| 05:04
+
| 00.09
|In this we will compare the string using the''' strcmp''' function
+
|String Library Functions
  
 
|-
 
|-
|05: 09
+
| 00.11
|Here we compare str1 ie: 'Ice' with 'Hello'
+
|We will do this with the help of some examples
  
 
|-
 
|-
| 05:14
+
| 00.15
|The result is stored in '''i'''
+
|To record this tutorial, I am using
  
 
|-
 
|-
| 05:17
+
| 00.18
|In this we will compare string 2 ie: 'Cream' with 'Cream'
+
| Ubuntu Operating System version 11.10,
  
 
|-
 
|-
| 05:23
+
| 00.22
|The result is stored in ''' j'''
+
|gcc Compiler Version 4.6.1
  
 
|-
 
|-
| 05:25
+
| 00.27
|Then we print both the results
+
|Let us start with an introduction to string library functions.
  
 
|-
 
|-
| 05:28
+
| 00.31
|and this is our return statement
+
|These are the group of functions implementing operations on strings.
  
 
|-
 
|-
| 05:31
+
|00.36
| Let us execute the program.
+
|Various operations such as copying, concatenation, searching etc are supported.
  
 
|-
 
|-
| 05:33
+
|00.44
|Come back to our terminal.
+
|Let us see some of the string library functions
  
 
|-
 
|-
| 05:35
+
|00.48
| To compile type
+
|Here we have the strncpy function
  
 
|-
 
|-
| 05:37
+
|00.52
|'''gcc''' space '''strcmp.c '''space '''-o''' space '''str3 '''
+
|The syntax for this is strncpy(char str1, char str2, and int n )
  
 
|-
 
|-
| 05:46
+
|01.02
|Press '''Enter'''
+
|It copies first n characters of string str2 into string str1
  
 
|-
 
|-
| 05:48
+
| 01.09
|Type  '''./str3'''
+
|example, char strncpy( char hello, char world, 2)
  
 
|-
 
|-
| 05:51
+
| 01.16
|The outpur is displayed as 1,0
+
|The output will be Wollo
  
 
|-
 
|-
| 05:55
+
|01.21
| Come back to our program
+
|Here we have Wo from the string 2 and rest of the characters from string 1
  
 
|-
 
|-
| 05:57
+
| 01.29
|Here we get 1
+
|Now we will see strncmp function, the syntax for this is strncmp(char str1, char str2, and int n) 
  
 
|-
 
|-
| 055:59
+
| 01.42
|and here we get as 0
+
|It will compare first n characters of string 2 with string 1
  
 
|-
 
|-
| 06:02
+
| 01.48
|Let us move back to our slides
+
|example int strncmp(char ice, char icecream, and  2);
  
 
|-
 
|-
| 06:04
+
|01.55
|Let us summarize,
+
|The output will be 0
  
 
|-
 
|-
| 06:06
+
| 01.58
| In this tutorial we learned,
+
|Now we will see how to use the string library functions.
  
 
|-
 
|-
| 06:08
+
| 02.02
|String library functions
+
|I am going to show you some of the commonly used string functions.
  
 
|-
 
|-
| 06:09
+
|02.07
| strlen()
+
|I have already typed the program on the editor,
  
 
|-
 
|-
| 06:11
+
|02.10
| strcpy()
+
| I will open it
  
 
|-
 
|-
| 06:13
+
|02.12
| strcmp()
+
|Here we have the string length function
 +
 
 
|-
 
|-
| 06:15
+
|02.15
| strncpy()
+
|Note that our filename is strlen.c.
  
 
|-
 
|-
| 06:17
+
|02.20
| and strncmp()
+
|In this we will find the length of the string
  
 +
|-
 +
|02.23
 +
|These are the header files as stdio.h and string.h.
  
 +
|-
 +
|02.29
 +
|This is our main function
  
 +
|-
 +
| 02.31
 +
|Here we have a character variable 'arr',
  
 
|-
 
|-
| 06:20
+
| 02.35
|   As an assignemnt,
+
|It stores a value 'Ashwini'
  
 
|-
 
|-
| 06:21
+
| 02.38
|Write a C Program to concatenate String best and String bus.
+
|Then we have an integer variable len1
  
 
|-
 
|-
| 06:25
+
| 02.42
 +
|Here we will find the lenght of the string using strlen funtion
 +
 
 +
|-
 +
| 02.48
 +
|The result will be stored in len1
 +
 
 +
|-
 +
| 02.52
 +
|Then we print the string and the length of the string.
 +
 
 +
|-
 +
|02.56
 +
|And this is our return statement
 +
 
 +
|-
 +
|02.59
 +
|Now let us execute the program
 +
 
 +
|-
 +
|03.01
 +
|Open the terminal window by pressing
 +
 
 +
 
 +
|-
 +
| 03.04
 +
|Ctrl, Alt and T keys simultaneously on your keyboard
 +
 
 +
|-
 +
| 03.09
 +
| To compile Type: "gcc" space "strlen.c" space “-o” space “str1”. Press Enter
 +
 
 +
|-
 +
| 03.19
 +
|Type (dot slash) ./str1. Press Enter
 +
 
 +
|-
 +
| 03.24
 +
|The output is displayed as
 +
 
 +
|-
 +
| 03.26
 +
|string = Ashwini, Length = 7
 +
 
 +
|-
 +
|03.30
 +
|You can count here. 1,2,3,4,5,6, and 7
 +
 
 +
|-
 +
| 03.37
 +
| Let us see another string function
 +
 
 +
|-
 +
| 03.40
 +
|Here we have the string copy fuction 
 +
 
 +
|-
 +
| 03.43
 +
|Note that our filename is strcpy.c
 +
 
 +
|-
 +
| 03.48
 +
|In this we will copy the source string into the target string
 +
 
 +
|-
 +
| 03.53
 +
|Here we have Ice in the source string, it will be copied to the target string
 +
 
 +
|-
 +
| 03.59
 +
|This is our strcpy function
 +
 
 +
|-
 +
| 04.02
 +
|Here we will print the source string and the target string
 +
 
 +
|-
 +
| 04.07
 +
|Let us execute and see 
 +
 
 +
|-
 +
| 04.09
 +
|Come back to our terminal
 +
 
 +
|-
 +
| 04.11
 +
| To compile type gcc space strcpy.c space hyphen o space str2. Press Enter
 +
 
 +
 
 +
|-
 +
| 04.20
 +
|Type (dot slash)./str2 Press Enter
 +
 
 +
|-
 +
| 04.24
 +
|The output is displayed as
 +
 
 +
|-
 +
| 04.26
 +
|source string = Ice
 +
 
 +
|-
 +
| 04.29
 +
|target string = Ice
 +
 
 +
|-
 +
| 04.32
 +
| Now let us see another string function
 +
 
 +
|-
 +
| 04.34
 +
|Now we will see the string compare function
 +
 
 +
|-
 +
| 04.37
 +
|Note that our filename is strcmp.c
 +
 
 +
|-
 +
| 04.42
 +
|In this we will comapre two strings
 +
 
 +
|-
 +
| 04.46
 +
|Here we have character variables as str1 and str2 
 +
 
 +
|-
 +
| 04.52
 +
|str1 stores the value as 'Ice' and str2 stores the value as 'Cream'.
 +
 
 +
|-
 +
| 04.58
 +
|Here we have interger variables as i and j
 +
 
 +
|-
 +
| 05.03
 +
|In this we will compare the string using the strcmp function
 +
 
 +
|-
 +
| 05.08
 +
|Here we compare str1 ie: 'Ice' with 'Hello'
 +
 
 +
|-
 +
| 05.14
 +
|The result is stored in i
 +
 
 +
|-
 +
| 05.16
 +
|In this we will compare string2 ie: 'Cream' with 'Cream'
 +
 
 +
|-
 +
| 05.23
 +
|The result is stored in j
 +
 
 +
|-
 +
| 05.25
 +
|Then we print both the results
 +
 
 +
|-
 +
| 05.28
 +
|And this is our return statement
 +
 
 +
|-
 +
| 05.31
 +
|Let us execute the program.
 +
 
 +
|-
 +
| 05.33
 +
|Come back to our terminal. 
 +
 
 +
|-
 +
| 05.35
 +
|To compile type gcc space strcmp.c space hyphen o space str3
 +
 
 +
|-
 +
| 05.46
 +
|Press Enter
 +
 
 +
|-
 +
| 05.47
 +
|Type (dot slash)./str3
 +
 
 +
|-
 +
| 05.50
 +
|The outpur is displayed as 1,0
 +
 
 +
|-
 +
| 05.54
 +
|Come back to our program
 +
 
 +
|-
 +
| 05.56
 +
|Here we get 1 and here we get as 0
 +
 
 +
|-
 +
| 06.01
 +
|Let us come back to our slides
 +
 
 +
|-
 +
| 06.04
 +
|Let us summarize,
 +
 
 +
|-
 +
| 06.06
 +
|In this tutorial we learned,
 +
 
 +
 
 +
|-
 +
| 06.07
 +
|String library functions
 +
 
 +
|-
 +
| 06.09
 +
|strlen()
 +
 
 +
|-
 +
| 06.11
 +
|strcpy()
 +
 
 +
|-
 +
| 06.13
 +
|strcmp()
 +
 
 +
 
 +
|-
 +
| 06.14
 +
|strncpy()
 +
 
 +
|-
 +
| 06.16
 +
|and strncmp()
 +
 
 +
|-
 +
| 06.19
 +
|As an assignemnt,
 +
 
 +
|-
 +
| 06.21
 +
|Write a C Program to concatenate String best and String bus.
 +
 
 +
|-
 +
| 06.25
 
|Hint: strcat(char str1, char str2);
 
|Hint: strcat(char str1, char str2);
  
 
|-
 
|-
| 06:33
+
| 06.32
|Also explore the other functions in string library.
+
|Also explore the other functions in string library.  
  
 
|-
 
|-
|   06:37
+
| 06.36
|   Watch the video available at the link shown below http://spoken-tutorial.org /What\_is\_a\_Spoken\_Tutorial
+
|Watch the video available at the link shown below
  
 
|-
 
|-
| 06:40
+
| 06.39
|It summarises the Spoken Tutorial project  
+
|It summarizes the Spoken Tutorial project  
  
 
|-
 
|-
| 06:43
+
| 06.42
|If you do not have good bandwidth, you can download and watch it.
+
|If you do not have good bandwidth, you can download and watch it  
  
 
|-
 
|-
| 06:47
+
| 06.46
| The Spoken Tutorial Project Team  
+
|The Spoken Tutorial Project Team  
  
 
|-
 
|-
| 06:49
+
| 06.49
 
|Conducts workshops using spoken tutorials  
 
|Conducts workshops using spoken tutorials  
  
 
|-
 
|-
| 06:52
+
| 06.52
 
|Gives certificates to those who pass an online test  
 
|Gives certificates to those who pass an online test  
  
 
|-
 
|-
| 06:56
+
| 06.56
|For more details, please write to contact [at] spoken hyphen tutorial dot org
+
|For more details, please write to, contact@spoken-tutorial.org  
 +
 
  
 
|-
 
|-
| 07:04
+
|07.03
| Spoken Tutorial Project is a part of the Talk to a Teacher project
+
|Spoken Tutorial Project is a part of the Talk to a Teacher project  
  
 
|-
 
|-
| 07:08
+
| 07.08
 
|It is supported by the National Mission on Education through ICT, MHRD, Government of India
 
|It is supported by the National Mission on Education through ICT, MHRD, Government of India
  
 
|-
 
|-
| 07:16
+
| 07.15
|More information on this Mission is available at: http://spoken-tutorial.org\NMEICT-Intro
+
|More information on this Mission is available at the link shown below
  
 
|-
 
|-
| 07:21
+
| 07.20
| This is Ashwini Patil from IIT Bombay.  
+
|This is Ashwini Patil from IIT Bombay signing of.  
  
 
|-
 
|-
| 07:24
+
| 07.24
|Thank you for joining.  
+
|Thank you for joining.
 
+
|}
+

Revision as of 15:38, 21 November 2013

Time Narration


00.01 Welcome to the spoken-tutorial on String Library Functions in C


00.07 In this tutorial we will learn,
00.09 String Library Functions
00.11 We will do this with the help of some examples
00.15 To record this tutorial, I am using
00.18 Ubuntu Operating System version 11.10,
00.22 gcc Compiler Version 4.6.1
00.27 Let us start with an introduction to string library functions.
00.31 These are the group of functions implementing operations on strings.
00.36 Various operations such as copying, concatenation, searching etc are supported.
00.44 Let us see some of the string library functions
00.48 Here we have the strncpy function
00.52 The syntax for this is strncpy(char str1, char str2, and int n )
01.02 It copies first n characters of string str2 into string str1
01.09 example, char strncpy( char hello, char world, 2)
01.16 The output will be Wollo
01.21 Here we have Wo from the string 2 and rest of the characters from string 1
01.29 Now we will see strncmp function, the syntax for this is strncmp(char str1, char str2, and int n)
01.42 It will compare first n characters of string 2 with string 1
01.48 example int strncmp(char ice, char icecream, and 2);
01.55 The output will be 0
01.58 Now we will see how to use the string library functions.
02.02 I am going to show you some of the commonly used string functions.
02.07 I have already typed the program on the editor,
02.10 I will open it
02.12 Here we have the string length function
02.15 Note that our filename is strlen.c.
02.20 In this we will find the length of the string
02.23 These are the header files as stdio.h and string.h.
02.29 This is our main function
02.31 Here we have a character variable 'arr',
02.35 It stores a value 'Ashwini'
02.38 Then we have an integer variable len1
02.42 Here we will find the lenght of the string using strlen funtion
02.48 The result will be stored in len1
02.52 Then we print the string and the length of the string.
02.56 And this is our return statement
02.59 Now let us execute the program
03.01 Open the terminal window by pressing


03.04 Ctrl, Alt and T keys simultaneously on your keyboard
03.09 To compile Type: "gcc" space "strlen.c" space “-o” space “str1”. Press Enter
03.19 Type (dot slash) ./str1. Press Enter
03.24 The output is displayed as
03.26 string = Ashwini, Length = 7
03.30 You can count here. 1,2,3,4,5,6, and 7
03.37 Let us see another string function
03.40 Here we have the string copy fuction
03.43 Note that our filename is strcpy.c
03.48 In this we will copy the source string into the target string
03.53 Here we have Ice in the source string, it will be copied to the target string
03.59 This is our strcpy function
04.02 Here we will print the source string and the target string
04.07 Let us execute and see
04.09 Come back to our terminal
04.11 To compile type gcc space strcpy.c space hyphen o space str2. Press Enter


04.20 Type (dot slash)./str2 Press Enter
04.24 The output is displayed as
04.26 source string = Ice
04.29 target string = Ice
04.32 Now let us see another string function
04.34 Now we will see the string compare function
04.37 Note that our filename is strcmp.c
04.42 In this we will comapre two strings
04.46 Here we have character variables as str1 and str2
04.52 str1 stores the value as 'Ice' and str2 stores the value as 'Cream'.
04.58 Here we have interger variables as i and j
05.03 In this we will compare the string using the strcmp function
05.08 Here we compare str1 ie: 'Ice' with 'Hello'
05.14 The result is stored in i
05.16 In this we will compare string2 ie: 'Cream' with 'Cream'
05.23 The result is stored in j
05.25 Then we print both the results
05.28 And this is our return statement
05.31 Let us execute the program.
05.33 Come back to our terminal.
05.35 To compile type gcc space strcmp.c space hyphen o space str3
05.46 Press Enter
05.47 Type (dot slash)./str3
05.50 The outpur is displayed as 1,0
05.54 Come back to our program
05.56 Here we get 1 and here we get as 0
06.01 Let us come back to our slides
06.04 Let us summarize,
06.06 In this tutorial we learned,


06.07 String library functions
06.09 strlen()
06.11 strcpy()
06.13 strcmp()


06.14 strncpy()
06.16 and strncmp()
06.19 As an assignemnt,
06.21 Write a C Program to concatenate String best and String bus.
06.25 Hint: strcat(char str1, char str2);
06.32 Also explore the other functions in string library.
06.36 Watch the video available at the link shown below
06.39 It summarizes the Spoken Tutorial project
06.42 If you do not have good bandwidth, you can download and watch it
06.46 The Spoken Tutorial Project Team
06.49 Conducts workshops using spoken tutorials
06.52 Gives certificates to those who pass an online test
06.56 For more details, please write to, contact@spoken-tutorial.org


07.03 Spoken Tutorial Project is a part of the Talk to a Teacher project
07.08 It is supported by the National Mission on Education through ICT, MHRD, Government of India
07.15 More information on this Mission is available at the link shown below
07.20 This is Ashwini Patil from IIT Bombay signing of.
07.24 border = 1 Time Narration


00.01 Welcome to the spoken-tutorial on String Library Functions in C


00.07 In this tutorial we will learn,
00.09 String Library Functions
00.11 We will do this with the help of some examples
00.15 To record this tutorial, I am using
00.18 Ubuntu Operating System version 11.10,
00.22 gcc Compiler Version 4.6.1
00.27 Let us start with an introduction to string library functions.
00.31 These are the group of functions implementing operations on strings.
00.36 Various operations such as copying, concatenation, searching etc are supported.
00.44 Let us see some of the string library functions
00.48 Here we have the strncpy function
00.52 The syntax for this is strncpy(char str1, char str2, and int n )
01.02 It copies first n characters of string str2 into string str1
01.09 example, char strncpy( char hello, char world, 2)
01.16 The output will be Wollo
01.21 Here we have Wo from the string 2 and rest of the characters from string 1
01.29 Now we will see strncmp function, the syntax for this is strncmp(char str1, char str2, and int n)
01.42 It will compare first n characters of string 2 with string 1
01.48 example int strncmp(char ice, char icecream, and 2);
01.55 The output will be 0
01.58 Now we will see how to use the string library functions.
02.02 I am going to show you some of the commonly used string functions.
02.07 I have already typed the program on the editor,
02.10 I will open it
02.12 Here we have the string length function
02.15 Note that our filename is strlen.c.
02.20 In this we will find the length of the string
02.23 These are the header files as stdio.h and string.h.
02.29 This is our main function
02.31 Here we have a character variable 'arr',
02.35 It stores a value 'Ashwini'
02.38 Then we have an integer variable len1
02.42 Here we will find the lenght of the string using strlen funtion
02.48 The result will be stored in len1
02.52 Then we print the string and the length of the string.
02.56 And this is our return statement
02.59 Now let us execute the program
03.01 Open the terminal window by pressing


03.04 Ctrl, Alt and T keys simultaneously on your keyboard
03.09 To compile Type: "gcc" space "strlen.c" space “-o” space “str1”. Press Enter
03.19 Type (dot slash) ./str1. Press Enter
03.24 The output is displayed as
03.26 string = Ashwini, Length = 7
03.30 You can count here. 1,2,3,4,5,6, and 7
03.37 Let us see another string function
03.40 Here we have the string copy fuction
03.43 Note that our filename is strcpy.c
03.48 In this we will copy the source string into the target string
03.53 Here we have Ice in the source string, it will be copied to the target string
03.59 This is our strcpy function
04.02 Here we will print the source string and the target string
04.07 Let us execute and see
04.09 Come back to our terminal
04.11 To compile type gcc space strcpy.c space hyphen o space str2. Press Enter


04.20 Type (dot slash)./str2 Press Enter
04.24 The output is displayed as
04.26 source string = Ice
04.29 target string = Ice
04.32 Now let us see another string function
04.34 Now we will see the string compare function
04.37 Note that our filename is strcmp.c
04.42 In this we will comapre two strings
04.46 Here we have character variables as str1 and str2
04.52 str1 stores the value as 'Ice' and str2 stores the value as 'Cream'.
04.58 Here we have interger variables as i and j
05.03 In this we will compare the string using the strcmp function
05.08 Here we compare str1 ie: 'Ice' with 'Hello'
05.14 The result is stored in i
05.16 In this we will compare string2 ie: 'Cream' with 'Cream'
05.23 The result is stored in j
05.25 Then we print both the results
05.28 And this is our return statement
05.31 Let us execute the program.
05.33 Come back to our terminal.
05.35 To compile type gcc space strcmp.c space hyphen o space str3
05.46 Press Enter
05.47 Type (dot slash)./str3
05.50 The outpur is displayed as 1,0
05.54 Come back to our program
05.56 Here we get 1 and here we get as 0
06.01 Let us come back to our slides
06.04 Let us summarize,
06.06 In this tutorial we learned,


06.07 String library functions
06.09 strlen()
06.11 strcpy()
06.13 strcmp()


06.14 strncpy()
06.16 and strncmp()
06.19 As an assignemnt,
06.21 Write a C Program to concatenate String best and String bus.
06.25 Hint: strcat(char str1, char str2);
06.32 Also explore the other functions in string library.
06.36 Watch the video available at the link shown below
06.39 It summarizes the Spoken Tutorial project
06.42 If you do not have good bandwidth, you can download and watch it
06.46 The Spoken Tutorial Project Team
06.49 Conducts workshops using spoken tutorials
06.52 Gives certificates to those who pass an online test
06.56 For more details, please write to, contact@spoken-tutorial.org


07.03 Spoken Tutorial Project is a part of the Talk to a Teacher project
07.08 It is supported by the National Mission on Education through ICT, MHRD, Government of India
07.15 More information on this Mission is available at the link shown below
07.20 This is Ashwini Patil from IIT Bombay signing of.
07.24 Thank you for joining.

Contributors and Content Editors

Krupali, PoojaMoolya, Pratik kamble, Sandhya.np14, Sneha