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

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with " {| Border = 1 ! <center>Time</center> ! <center>Narration</center> |- | 00:01 |Hello and welcome to the spoken tutorial on''' Command Line Arguments.''' |- | 00:07 |In this...")
 
Line 118: Line 118:
 
|You can see the output as:
 
|You can see the output as:
 
'''Total number of arguments are 1 '''
 
'''Total number of arguments are 1 '''
 +
 
'''The first argument is null '''
 
'''The first argument is null '''
 +
 
'''arguments are ./args '''
 
'''arguments are ./args '''
  
Line 149: Line 151:
 
|Now we can see the output:
 
|Now we can see the output:
 
'''Total number of arguments are 4 '''
 
'''Total number of arguments are 4 '''
 +
 
'''The first argument is Sunday '''
 
'''The first argument is Sunday '''
 +
 
'''Argument are ./args ''' '''Sunday Monday ''' and '''Tuesday '''.
 
'''Argument are ./args ''' '''Sunday Monday ''' and '''Tuesday '''.
  

Revision as of 11:38, 20 November 2015

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 Filename 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+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 Arguments are only one ie. dot slash args
03:31 Now let us execute again
03:34 Press the uparrow 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

Argument 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 zeroeth argument always gives executable filename.
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 summarises 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: 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