Difference between revisions of "C-and-C++/C4/Understanding-Pointers/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(7 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{| border = 1
 
{| border = 1
 
 
|'''Time'''
 
|'''Time'''
 
 
|'''Narration'''
 
|'''Narration'''
 
  
 
|-
 
|-
| 00.01
+
| 00:01
|Welcome to the spoken tutorial on Pointers in C and C++  
+
|Welcome to the spoken tutorial on '''Pointers in C and C++ '''.
  
 
|-
 
|-
| 00.06
+
| 00:06
|In this tutorial we will learn,    
+
|In this tutorial we will learn:    
  
 
|-
 
|-
| 00.08
+
| 00:08
|Pointers.
+
|Pointers  
  
 
|-
 
|-
| 00.10
+
| 00:10
|To create Pointers.
+
|To create Pointers  
  
 
|-
 
|-
| 00.12
+
| 00:12
 
|And operations on Pointers.  
 
|And operations on Pointers.  
  
 
|-
 
|-
| 00.14
+
| 00:14
| We will do this with the help of an example
+
| We will do this with the help of an example.
  
 
|-
 
|-
| 00.18
+
| 00:18
|To record this tutorial I am using Ubuntu operating system version 11.10
+
|To record this tutorial, I am using '''Ubuntu operating system''' version 11.10,
  
 
|-
 
|-
| 00.25
+
| 00:25
| gcc and g++ compiler version 4.6.1 on Ubuntu
+
| '''gcc and g++ compiler''' version 4.6.1 on Ubuntu.
  
 
|-
 
|-
| 00.31
+
| 00:31
|Let us start with an introduction to pointers
+
|Let us start with an introduction to pointers.
  
 
|-
 
|-
|00.34
+
|00:34
 
|Pointers point to the locations in memory.  
 
|Pointers point to the locations in memory.  
 
   
 
   
Line 51: Line 48:
  
 
|-
 
|-
| 00.41
+
| 00:41
 
|It also gives value stored at that address.  
 
|It also gives value stored at that address.  
  
 
|-
 
|-
| 00.45
+
| 00:45
|Now, let us see an example on pointers
+
|Now, let us see an example on pointers.
  
 
|-
 
|-
| 00.48
+
| 00:48
|Note that our file name is pointers_demo.c
+
|Note that our file name is '''pointers_demo.c'''.
  
 
|-
 
|-
| 00.54
+
| 00:54
|Let us go through the code now
+
|Let us go through the code now.
  
 
|-
 
|-
| 00.56
+
| 00:56
|This is our header file as stdio.h
+
|This is our header file as '''stdio.h'''.
  
 
|-
 
|-
| 01.00
+
| 01:00
|This is our main function
+
|This is our '''main()''' function.
  
 
|-
 
|-
| 01.03
+
| 01:03
|Here we have long integer num assigned value 10.
+
|Here we have '''long integer num''', assigned value '''10.'''
  
 
|-
 
|-
| 01.09
+
| 01:09
|Then we have declared a pointer ptr.  
+
|Then we have declared a pointer '''ptr'''.  
  
 
|-
 
|-
| 01.12
+
| 01:12
 
|Asterisk sign is used to declare a pointer.  
 
|Asterisk sign is used to declare a pointer.  
  
 
|-
 
|-
| 01.16
+
| 01:16
|This pointer can point to type long  int.  
+
|This pointer can point to type '''long  int. '''
  
 
|-
 
|-
| 01.20
+
| 01:20
|In the printf statement ampersand is used for retrieving memory address of the variable.  
+
|In the 'printf' statement, ampersand is used for retrieving memory address of the variable.  
  
 
|-
 
|-
|01.28
+
|01:28
|So ampersand num will give the memory address of num.  
+
|So, ampersand num (&num) will give the memory address of '''num'''.  
  
 
|-
 
|-
| 01.33
+
| 01:33
 
|This statement will print the address of the variable num.  
 
|This statement will print the address of the variable num.  
  
 
|-
 
|-
| 01.37
+
| 01:37
|Over here ptr stores the address of num.  
+
|Over here, ptr stores the address of num.  
  
 
|-
 
|-
| 01.41
+
| 01:41
 
|This statement will print the address of ptr.  
 
|This statement will print the address of ptr.  
 
  
 
|-
 
|-
| 01.45
+
| 01:45
|Sizeof function will give the size of ptr.  
+
|'''sizeof()''' function will give the size of ptr.  
  
 
|-
 
|-
|01.49
+
|01:49
 
|This is will give the value of ptr.  
 
|This is will give the value of ptr.  
  
 
|-
 
|-
|01.51
+
|01:51
 
|That is the memory address of num.  
 
|That is the memory address of num.  
  
 
|-
 
|-
|01.54
+
|01:54
 
|And here asterisk ptr will give the value at the address.  
 
|And here asterisk ptr will give the value at the address.  
  
 
|-
 
|-
|01.59
+
|01:59
|So using asterik will not give the memory address.  
+
|So, using asterisk will not give the memory address.  
  
 
|-
 
|-
|02.03
+
|02:03
 
|Instead it will give the value.  
 
|Instead it will give the value.  
  
 
|-
 
|-
|02.06
+
|02:06
|%ld is a format specifier for the long int
+
|'''%ld''' is a format specifier for the '''long int'''.
  
 
|-
 
|-
|02.10
+
|02:10
|Now, let us execute the program
+
|Now, let us execute the program.
  
 
|-
 
|-
|02.13
+
|02:13
|Open the terminal window by pressing Ctrl, Alt and T keys simultaneously on your keyboard
+
|Open the terminal window by pressing '''Ctrl, Alt''' and '''T''' keys simultaneously on your keyboard.
  
 
|-
 
|-
|02.21
+
|02:21
|To compile type gcc space  pointers underscore demo dot c space hyphen o space point
+
|To compile, type '''gcc space  pointers underscore demo dot c space hyphen o space point'''
 
+
  
 
|-
 
|-
|02.32
+
|02:32
|Press Enter
+
|Press '''Enter'''.
  
 
|-
 
|-
|02.34
+
|02:34
|Type dot slash point. Press Enter
+
|Type '''dot slash point'''. Press '''Enter'''.
  
 
|-
 
|-
|02.39
+
|02:39
|The output is displayed
+
|The output is displayed.
  
 
|-
 
|-
| 02.42
+
| 02:42
|We see that the num address and ptr value is same.
+
|We see that the num address and ptr value is same  
  
 
|-
 
|-
| 02.48
+
| 02:48
| Where as memory address of num and ptr are different.  
+
| where as memory address of num and ptr are different.  
  
 
|-
 
|-
| 02.53
+
| 02:53
|Then the size of pointer is 8 bytes.  
+
|Then the size of pointer is '''8 bytes.'''
  
 
|-
 
|-
| 02.57
+
| 02:57
| Also the value pointed by ptr is 10 which was assigned to num.  
+
| Also the value pointed by '''ptr''' is 10 which was assigned to '''num.'''
  
 
|-
 
|-
| 03.03
+
| 03:03
 
| Now let us see the same program in  C++.  
 
| Now let us see the same program in  C++.  
  
 
|-
 
|-
| 03.07
+
| 03:07
| Note that our file name is pointer underscore demo.cpp
+
| Note that our file name is '''pointer underscore demo.cpp'''.
  
 
|-
 
|-
| 03.13
+
| 03:13
| Here we have few changes like the header file as iostream
+
| Here we have a few changes like the header file as '''iostream'''.
  
 
|-
 
|-
| 03.19
+
| 03:19
|Then we are using the std namespace
+
|Then we are using the '''std namespace'''.
  
 
|-
 
|-
| 03.23
+
| 03:23
|And we have the cout function in place of printf function
+
|And here we have the '''cout''' function in place of printf() function.
  
 
|-
 
|-
| 03.28
+
| 03:28
|Rest all the things are similar
+
|Rest all the things are similar.
  
 
|-
 
|-
| 03.30
+
| 03:30
 
|Let us execute the program. Come back to our terminal.
 
|Let us execute the program. Come back to our terminal.
  
 
|-
 
|-
| 03.34
+
| 03:34
|To compile type g++ space pointers_demo.cpp space hyphen o space point1, press Enter
+
|To compile, type '''g++ space pointers_demo.cpp space hyphen o space point1''', press Enter.
  
 
|-
 
|-
| 03.50
+
| 03:50
|Type dot slash point1, press Enter
+
|Type '''dot slash point1''', press '''Enter'''.
  
 
|-
 
|-
| 03.55
+
| 03:55
| We can see that the output is similar to our C program
+
| We can see that the output is similar to our C program.
  
 
|-
 
|-
| 04.00
+
| 04:00
 
|This brings us to the end of this tutorial.
 
|This brings us to the end of this tutorial.
  
 
|-
 
|-
| 04.03
+
| 04:03
| Come back to our slide
+
| Come back to our slide.
 
+
|-
+
| 04.05
+
|Let us summarize
+
  
 
|-
 
|-
| 04.06
+
| 04:05
|In this tutorial, we learnt
+
|Let us summarize.In this tutorial, we learnt:
  
 
|-
 
|-
| 04.08
+
| 04:08
 
|About the pointer.  
 
|About the pointer.  
  
 
|-
 
|-
| 04.10
+
| 04:10
 
|To create a pointer.  
 
|To create a pointer.  
  
 
|-
 
|-
| 04.12
+
| 04:12
 
|And operation on pointer.  
 
|And operation on pointer.  
  
 
|-
 
|-
| 04.14
+
| 04:14
|As an assignment, write a C and C++ program,
+
|As an assignment, write a C and C++ program  
  
 
|-
 
|-
| 04.18
+
| 04:18
|To declare a variable and pointer.  
+
|to declare a variable and pointer.  
  
 
|-
 
|-
| 04.21
+
| 04:21
 
| Store the address of variable in the pointer.  
 
| Store the address of variable in the pointer.  
  
 
|-
 
|-
| 04.24
+
| 04:24
 
|And print the value of the pointer.  
 
|And print the value of the pointer.  
  
 
|-
 
|-
| 04.27
+
| 04:27
|Watch the video available at the link shown below
+
|Watch the video available at the link shown below.
  
 
|-
 
|-
| 04.30
+
| 04:30
|It summarizes the Spoken Tutorial project  
+
|It summarizes the Spoken Tutorial project.
  
 
|-
 
|-
| 04.33
+
| 04:33
|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.
  
 
|-
 
|-
| 04.37
+
| 04:37
|The Spoken Tutorial Project Team  
+
|The Spoken Tutorial Project Team:
  
 
|-
 
|-
| 04.39
+
| 04:39
|Conducts workshops using spoken tutorials  
+
|Conducts workshops using spoken tutorials.
  
 
|-
 
|-
|04.43
+
|04:43
|Gives certificates to those who pass an online test  
+
|Gives certificates to those who pass an online test.
  
 
|-
 
|-
| 04.47
+
| 04:47
|For more details, please write to, contact@spoken-tutorial.org  
+
|For more details, please write to contact@spoken-tutorial.org.
  
 
|-
 
|-
| 04.53
+
| 04:53
|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.
  
 
|-
 
|-
| 04.58
+
| 04:58
|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.
  
 
|-
 
|-
| 05.06
+
| 05:06
|More information on this Mission is available at the link shown below
+
|More information on this mission is available at the link shown below.
  
 
|-
 
|-
| 05.10
+
| 05:10
| This is Ashwini Patil from IIT Bombay signing off  
+
| This is Ashwini Patil from IIT Bombay, signing off.
  
 
|-
 
|-
| 05.14
+
| 05:14
 
|Thank You for joining.
 
|Thank You for joining.

Latest revision as of 14:53, 24 March 2017

Time Narration
00:01 Welcome to the spoken tutorial on Pointers in C and C++ .
00:06 In this tutorial we will learn:
00:08 Pointers
00:10 To create Pointers
00:12 And operations on Pointers.
00:14 We will do this with the help of an example.
00:18 To record this tutorial, I am using Ubuntu operating system version 11.10,
00:25 gcc and g++ compiler version 4.6.1 on Ubuntu.
00:31 Let us start with an introduction to pointers.
00:34 Pointers point to the locations in memory.
00.38 Pointers store the memory address.
00:41 It also gives value stored at that address.
00:45 Now, let us see an example on pointers.
00:48 Note that our file name is pointers_demo.c.
00:54 Let us go through the code now.
00:56 This is our header file as stdio.h.
01:00 This is our main() function.
01:03 Here we have long integer num, assigned value 10.
01:09 Then we have declared a pointer ptr.
01:12 Asterisk sign is used to declare a pointer.
01:16 This pointer can point to type long int.
01:20 In the 'printf' statement, ampersand is used for retrieving memory address of the variable.
01:28 So, ampersand num (&num) will give the memory address of num.
01:33 This statement will print the address of the variable num.
01:37 Over here, ptr stores the address of num.
01:41 This statement will print the address of ptr.
01:45 sizeof() function will give the size of ptr.
01:49 This is will give the value of ptr.
01:51 That is the memory address of num.
01:54 And here asterisk ptr will give the value at the address.
01:59 So, using asterisk will not give the memory address.
02:03 Instead it will give the value.
02:06 %ld is a format specifier for the long int.
02:10 Now, let us execute the program.
02:13 Open the terminal window by pressing Ctrl, Alt and T keys simultaneously on your keyboard.
02:21 To compile, type gcc space pointers underscore demo dot c space hyphen o space point
02:32 Press Enter.
02:34 Type dot slash point. Press Enter.
02:39 The output is displayed.
02:42 We see that the num address and ptr value is same
02:48 where as memory address of num and ptr are different.
02:53 Then the size of pointer is 8 bytes.
02:57 Also the value pointed by ptr is 10 which was assigned to num.
03:03 Now let us see the same program in C++.
03:07 Note that our file name is pointer underscore demo.cpp.
03:13 Here we have a few changes like the header file as iostream.
03:19 Then we are using the std namespace.
03:23 And here we have the cout function in place of printf() function.
03:28 Rest all the things are similar.
03:30 Let us execute the program. Come back to our terminal.
03:34 To compile, type g++ space pointers_demo.cpp space hyphen o space point1, press Enter.
03:50 Type dot slash point1, press Enter.
03:55 We can see that the output is similar to our C program.
04:00 This brings us to the end of this tutorial.
04:03 Come back to our slide.
04:05 Let us summarize.In this tutorial, we learnt:
04:08 About the pointer.
04:10 To create a pointer.
04:12 And operation on pointer.
04:14 As an assignment, write a C and C++ program
04:18 to declare a variable and pointer.
04:21 Store the address of variable in the pointer.
04:24 And print the value of the pointer.
04:27 Watch the video available at the link shown below.
04:30 It summarizes the Spoken Tutorial project.
04:33 If you do not have good bandwidth, you can download and watch it.
04:37 The Spoken Tutorial Project Team:
04:39 Conducts workshops using spoken tutorials.
04:43 Gives certificates to those who pass an online test.
04:47 For more details, please write to contact@spoken-tutorial.org.
04:53 Spoken Tutorial Project is a part of the Talk to a Teacher project.
04:58 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
05:06 More information on this mission is available at the link shown below.
05:10 This is Ashwini Patil from IIT Bombay, signing off.
05:14 Thank You for joining.

Contributors and Content Editors

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