C-and-C++/C4/Understanding-Pointers/Gujarati

From Script | Spoken-Tutorial
Revision as of 11:59, 11 September 2013 by Krupali (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Time' Narration
00:02 Welcome to the spoken tutorial on Pointers in C and C++
00:07 In this tutorial we will learn
00:09 Pointers.
00:10 To create Pointers.
00:12 And operations on Pointer.
00:15 We will do this with the help of an example.
00:18 To record this tutorial I am using

Ubuntu OS v11.10

gcc and g++ compiler v4.6.1 on ubuntu.


00:32 Let us start with an introduction to pointers.
00:35 Pointers point to the locations in memory.


00:39 Pointers store a memory address.


00:42 It also gives value stored at that address.
00:45 Now let us see an example on pointers.
00:49 Note that our file name is pointer_demo.c


00:54 Let us go through the code now
00:57 This is our headerfile as stdio.h
01:01 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:13 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 will give the memory address of num.
01:34 This statement will print the address of the variable num.
01:38 Over here ptr stores the address of num.
01:48 This statement will print the address of ptr.
01:46 Size of function will give the size of ptr.
01:49 This is will give the value of ptr.
01:52 That is the memory address of num.
01:55 And here asterisk ptr will give the value at the address.

'

02:00 So using asterik will not give the memory address.
02:03 Instead it will give the value. %ld is the format specifier for long int.
02:11 Now let us execute the program.
02:14 Open the terminal window by pressing ctrl+alt+t keys simultaneously on your keyboard.
02:22 To compile type:
02:23 gcc pointer_demo.c -o point
02:33 Press Enter
02:35 type ./point.Press Enter
02:39 The output is displayed
02:42 We see that the num address and ptr value is same.
02:48 Whereas 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:04 Now let us see the same program in C++.
03:08 Note that our filename is pointers_demo.cpp
03:14 Here we have a few changes like the header file as isotream

'

03:20 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:31 Let us execute the program
03:33 Come back to our terminal.
03:35 To compile type:
03:36 g++ pointers_demo.cpp -o point1
03:48 Press Enter
03:51 Type:./point1. Press Enter
03:56 You 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 slides.
04:06 Let us summarize:
04:07 In this tutorial we learnt.
04:09 About the pointer.
04:11 To create a pointer.
04:12 And Operation on pointer.
04:15 As an assignment write a C and C++ program,


04:18 To declare a variable and pointer.
04:22 Store the address of variable in the pointer.
04:25 And Print the value of the pointer.


04:28 Watch the video available at http://spoken-tutorial.org/What_is_a_Spoken_Tutorial
04:31 It summarizes the Spoken Tutorial project
04:33 If you do not have good bandwidth, you can download and watch it


04:38 The Spoken Tutorial Project Team
04:40 Conducts workshops using spoken tutorials
04:43 Gives certificates for those who pass an online test


04:47 For more details, please write to contact@spoken-tutorial.org


04:54 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


05:11 This is Ashwini Patil from IIT Bomabay. Siginning off.
05:15 Thanks for joining.

Contributors and Content Editors

Jyotisolanki, Krupali, Pratik kamble