Difference between revisions of "Advance-C/C2/Command-line-arguments-in-C/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
 
{| Border = 1
 
{| Border = 1
! <center>Time</center>
+
| '''Time'''
! <center>Narration</center>
+
|'''Narration'''
  
 
|-
 
|-
Line 10: Line 9:
 
|-
 
|-
 
| 00:07
 
| 00:07
|In this tutorial, we will learn about  '''main''' function with '''arguments''', with an example.
+
|In this tutorial, we will learn about  '''main()''' function with '''arguments''', with an example.
  
 
|-
 
|-
Line 30: Line 29:
 
|-
 
|-
 
| 00:45
 
| 00:45
|Filename is ''''main hyphen with hyphen args.c''''.
+
|File name is '''main hyphen with hyphen args.c'''.
  
 
|-
 
|-
Line 43: Line 42:
 
| 01:01
 
| 01:01
 
|'''stdlib.h header file''' defines-
 
|'''stdlib.h header file''' defines-
* '''Numeric conversion function'''
+
'''Numeric conversion function'''
* '''Pseudo-random numbers'''
+
'''Pseudo-random numbers'''
* '''Generation function'''
+
'''Generation function'''
* '''Memory allocation'''
+
'''Memory allocation'''
* '''Process control functions'''.
+
'''Process control functions'''.
  
 
|-
 
|-
 
|01:16
 
|01:16
|This is our ''''main' function.''' Inside this, we have passed two '''arguments'''-
+
|This is our '''main()''' function. Inside this, we have passed two arguments-
 
'''int argc,  char  asterisk asterisk argv''' (**argv).
 
'''int argc,  char  asterisk asterisk argv''' (**argv).
  
 
|-
 
|-
 
| 01:28
 
| 01:28
|'''“argc”''' refers to the number of '''command line arguments''' passed to the program.
+
| '''argc''' refers to the number of '''command line arguments''' passed to the program.
  
 
|-
 
|-
Line 64: Line 63:
 
|-
 
|-
 
| 01:38
 
| 01:38
|'''argv''' contains actual '''arguments''' starting from '''index 0'''.
+
|'''argv''' contains actual '''argument'''s starting from '''index 0'''.
  
 
|-
 
|-
Line 92: Line 91:
 
|-
 
|-
 
| 02:13
 
| 02:13
|''''while' condition''' will decrement the number of '''arguments'''.
+
|''''while' condition''' will decrement the number of arguments.
  
 
|-
 
|-
Line 104: Line 103:
 
|-
 
|-
 
| 02:27
 
| 02:27
|Let us open the '''terminal''' by pressing '''Ctrl+Alt+T''' keys simultaneously on your keyboard.
+
|Let us open the '''terminal''' by pressing '''Ctrl+Alt''' and '''T''' keys simultaneously on your keyboard.
  
 
|-
 
|-
Line 117: Line 116:
 
| 02:54
 
| 02:54
 
|You can see the output as:
 
|You can see the output as:
"Total number of arguments are 1".
+
 
"The first argument is null"  
+
'''"Total number of arguments are 1"'''
"arguments are ./args"  
+
 +
'''"The first argument is null"'''
 +
 +
'''"arguments are ./args"'''
  
 
|-
 
|-
Line 131: Line 133:
 
|-
 
|-
 
| 03:19
 
| 03:19
|'''The first argument is (null) '''as we have not passed any argument to the program.  
+
|'''The first argument is null '''as we have not passed any argument to the program.  
  
 
|-
 
|-
 
| 03:26
 
| 03:26
|'''Arguments''' are only one i.e. '''dot slash args'''.
+
|'''Argument''' is only one i.e. '''dot slash args'''.
  
 
|-
 
|-
Line 143: Line 145:
 
|-
 
|-
 
| 03:34
 
| 03:34
|Press the up-arrow key '''space''' type: '''Sunday space Monday space Tuesday'''. Press '''Enter'''
+
|Press the up-arrow key '''space''' type: '''Sunday space Monday space Tuesday'''. Press '''Enter'''.
  
 
|-
 
|-
Line 160: Line 162:
 
|-
 
|-
 
| 04:06
 
| 04:06
|Total number of arguments are 4 as '''./args, Sunday, Monday''' and '''Tuesday.'''
+
|Total number of arguments are 4 as- '''./args, Sunday, Monday''' and '''Tuesday.'''
  
 
|-
 
|-
 
| 04:14
 
| 04:14
|The '''first argument''' is '''Sunday '''.
+
|The first argument is '''Sunday'''.
  
 
|-
 
|-
 
| 04:17
 
| 04:17
|The '''zeroth argument''' always gives executable filename.
+
|The zeroth argument always gives executable file-name.
  
 
|-
 
|-
Line 176: Line 178:
 
|-
 
|-
 
| 04:25
 
| 04:25
|'''Monday '''is assigned to second argument.
+
|'''Monday''' is assigned to second argument.
  
 
|-
 
|-
 
| 04:28
 
| 04:28
|'''Tuesday '''is assigned to third argument.  
+
|'''Tuesday''' is assigned to third argument.  
  
 
|-
 
|-
Line 189: Line 191:
 
| 04:37
 
| 04:37
 
|In this tutorial, we learnt:
 
|In this tutorial, we learnt:
* '''Command line arguments'''
+
'''Command line arguments'''
* '''argc'''
+
'''argc'''
* '''argv'''.
+
'''argv'''.
  
 
|-
 
|-
 
| 04:45
 
| 04:45
|As an assignment, execute the program with different '''arguments'''.
+
|As an assignment, execute the program with different '''argument'''s.
  
 
|-
 
|-
Line 211: Line 213:
 
|-
 
|-
 
| 05:02
 
| 05:02
|The Spoken Tutorial Project team: * Conducts workshops using spoken tutorials.  
+
|The Spoken Tutorial Project team: Conducts workshops using spoken tutorials.  
  
 
|-
 
|-
 
| 05:08
 
| 05:08
|* Gives certificates to those who pass an online test. For more details, please write to '''contact@spoken-tutorial.org'''
+
|Gives certificates to those who pass an online test. For more details, please write to '''contact@spoken-tutorial.org'''
  
 
|-
 
|-
Line 227: Line 229:
 
|-
 
|-
 
| 05:30
 
| 05:30
|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: http://spoken-tutorial.org\NMEICT-Intro.
  
 
|-
 
|-
 
| 05:36
 
| 05:36
|This is Ashwini Patil from IIT Bombay, signning off.
+
|This is Ashwini Patil from IIT Bombay, signning off.Thank you for joining.
Thank you for joining.
+
  
 
|}
 
|}

Latest revision as of 12:17, 22 February 2017

Time Narration
00:01 Hello and welcome to the spoken tutorial on Command Line Arguments.
00:07 In this tutorial, we will learn about main() function with arguments, with an example.
00:15 For this tutorial, I am using Ubuntu Operating system version 11.10 and gcc Compiler version 4.6.1 on Ubuntu.
00:27 To follow this tutorial, you should be familiar with C tutorials.
00:33 If not, for relevant tutorials, please visit our website which is as shown.
00:39 Let us start with our program. I have a code file. I will open it.
00:45 File name is main hyphen with hyphen args.c.
00:50 Let me explain the program.
00:53 These are the header files. stdio.h defines core input and output functions.
01:01 stdlib.h header file defines-

Numeric conversion function Pseudo-random numbers Generation function Memory allocation Process control functions.

01:16 This is our main() function. Inside this, we have passed two arguments-

int argc, char asterisk asterisk argv (**argv).

01:28 argc refers to the number of command line arguments passed to the program.
01:34 This includes the actual name of the program.
01:38 argv contains actual arguments starting from index 0.
01:44 Index 0 is the name of the program.
01:48 Index 1 will be the first argument passed to the program.
01:53 Index 2 will be the second argument passed to the program and so on.
01:59 This statement will display the total number of arguments passed to the program.
02:05 This will display the first argument passed to the program.
02:09 1 represents the argument at index 1.
02:13 'while' condition will decrement the number of arguments.
02:18 This statement will print all the arguments passed to the program.
02:23 At the end, we have return 0 statement.
02:27 Let us open the terminal by pressing Ctrl+Alt and T keys simultaneously on your keyboard.
02:35 Type: gcc space main hyphen with hyphen args.c space hyphen o space args. Press Enter.
02:49 Type: dot slash args. Press Enter.
02:54 You can see the output as:

"Total number of arguments are 1"

"The first argument is null"

"arguments are ./args"

03:06 Command line arguments are given during execution.
03:11 Total number of arguments are 1 as the zeroth argument is the executable filename itself.
03:19 The first argument is null as we have not passed any argument to the program.
03:26 Argument is only one i.e. dot slash args.
03:31 Now let us execute again.
03:34 Press the up-arrow key space type: Sunday space Monday space Tuesday. Press Enter.
03:47 Now we can see the output:

Total number of arguments are 4

The first argument is Sunday

Arguments are ./args Sunday Monday and Tuesday .

04:04 Let me explain the output.
04:06 Total number of arguments are 4 as- ./args, Sunday, Monday and Tuesday.
04:14 The first argument is Sunday.
04:17 The zeroth argument always gives executable file-name.
04:22 Sunday is assigned to first argument.
04:25 Monday is assigned to second argument.
04:28 Tuesday is assigned to third argument.
04:31 This brings us to the end of this tutorial. Let us summarize.
04:37 In this tutorial, we learnt:

Command line arguments argc argv.

04:45 As an assignment, execute the program with different arguments.
04:51 Watch the video available at the link shown below.
04:54 It summarizes the Spoken Tutorial project.
04:57 If you do not have good bandwidth, you can download and watch it.
05:02 The Spoken Tutorial Project team: Conducts workshops using spoken tutorials.
05:08 Gives certificates to those who pass an online test. For more details, please write to contact@spoken-tutorial.org
05:18 Spoken Tutorial Project is a part of the Talk to a Teacher project.
05:22 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
05:30 More information on this mission is available at the link shown below: http://spoken-tutorial.org\NMEICT-Intro.
05:36 This is Ashwini Patil from IIT Bombay, signning off.Thank you for joining.

Contributors and Content Editors

PoojaMoolya, Pratik kamble, Sandhya.np14