Difference between revisions of "C-and-C++/C4/File-Handling-In-C/English-timed"
From Script | Spoken-Tutorial
PoojaMoolya (Talk | contribs) |
PoojaMoolya (Talk | contribs) |
||
Line 1: | Line 1: | ||
{| border = 1 | {| border = 1 | ||
− | | | + | |Time |
− | | | + | |Narration |
|- | |- | ||
− | | 00 | + | | 00:01 |
|Welcome to the spoken-tutorial on files in C. | |Welcome to the spoken-tutorial on files in C. | ||
|- | |- | ||
− | | 00 | + | | 00:05 |
|In this tutorial we will learn how, | |In this tutorial we will learn how, | ||
|- | |- | ||
− | | 00 | + | | 00:08 |
|To open a file. | |To open a file. | ||
− | |||
|- | |- | ||
− | | 00 | + | | 00:10 |
|How to read data from a file. | |How to read data from a file. | ||
− | |||
|- | |- | ||
− | | 00 | + | | 00:12 |
|How to write data into a file. | |How to write data into a file. | ||
− | |||
|- | |- | ||
− | | 00 | + | | 00:15 |
|Few examples. | |Few examples. | ||
|- | |- | ||
− | | 00 | + | | 00:17 |
|To record this tutorial, I am using, | |To record this tutorial, I am using, | ||
|- | |- | ||
− | | 00 | + | | 00:20 |
| Ubuntu Operating System version 11.10, | | Ubuntu Operating System version 11.10, | ||
− | |||
|- | |- | ||
− | | 00 | + | | 00:24 |
|gcc Compiler version 4.6.1. | |gcc Compiler version 4.6.1. | ||
− | |||
|- | |- | ||
− | | 00 | + | | 00:28 |
| Let us start with the introduction to files. | | Let us start with the introduction to files. | ||
+ | |||
|- | |- | ||
− | | 00 | + | | 00:31 |
|File is a collection of data. | |File is a collection of data. | ||
− | |||
|- | |- | ||
− | |00 | + | |00:34 |
|It can be a database, a program, a letter or anything. | |It can be a database, a program, a letter or anything. | ||
|- | |- | ||
− | |00 | + | |00:39 |
|We can create a file and access it using C. | |We can create a file and access it using C. | ||
− | |||
|- | |- | ||
− | |00 | + | |00:44 |
|Now let us see an example on '''file handling''' in '''C.''' | |Now let us see an example on '''file handling''' in '''C.''' | ||
− | |||
|- | |- | ||
− | | 00 | + | | 00:48 |
|I have a written program. | |I have a written program. | ||
|- | |- | ||
− | | 00 | + | | 00:50 |
| Let's take a look. | | Let's take a look. | ||
− | |||
|- | |- | ||
− | | 00 | + | | 00:51 |
|Note that our filename is '''file.c ''' | |Note that our filename is '''file.c ''' | ||
|- | |- | ||
− | | 00 | + | | 00:55 |
|In this program we will create a file and write data into it. | |In this program we will create a file and write data into it. | ||
− | |||
|- | |- | ||
− | | 01 | + | | 01:01 |
|Let me explain the code now | |Let me explain the code now | ||
|- | |- | ||
− | | 01 | + | | 01:03 |
|This is our '''header file. ''' | |This is our '''header file. ''' | ||
|- | |- | ||
− | | 01 | + | | 01:05 |
|This is our '''main function. ''' | |This is our '''main function. ''' | ||
|- | |- | ||
− | |01 | + | |01:07 |
|To define a '''file''' variable we use the type '''FILE. ''' | |To define a '''file''' variable we use the type '''FILE. ''' | ||
|- | |- | ||
− | | 01 | + | | 01:12 |
|The '''FILE variable''' is defined under the '''header stdio.h''' | |The '''FILE variable''' is defined under the '''header stdio.h''' | ||
− | |||
|- | |- | ||
− | | 01 | + | | 01:19 |
|'''*fp''' is a pointer to the '''FILE variable. ''' | |'''*fp''' is a pointer to the '''FILE variable. ''' | ||
− | |||
|- | |- | ||
− | | 01 | + | | 01:22 |
|It will store all the information about the '''file. ''' | |It will store all the information about the '''file. ''' | ||
− | |||
|- | |- | ||
− | | 01 | + | | 01:26 |
|Like its name, status and current information. | |Like its name, status and current information. | ||
− | |||
|- | |- | ||
− | |01 | + | |01:31 |
|Let us go back to our slides. | |Let us go back to our slides. | ||
|- | |- | ||
− | |01 | + | |01:33 |
|Now we will see the syntax to open a file. | |Now we will see the syntax to open a file. | ||
+ | |||
|- | |- | ||
− | |01 | + | |01:37 |
|Here, the '''fopen function''' opens a stream. | |Here, the '''fopen function''' opens a stream. | ||
− | |||
|- | |- | ||
− | |01 | + | |01:42 |
|Then it links the '''file''' with the stream. | |Then it links the '''file''' with the stream. | ||
− | |||
|- | |- | ||
− | |01 | + | |01:44 |
|filename is the name of the file that we want to open or create. | |filename is the name of the file that we want to open or create. | ||
− | |||
|- | |- | ||
− | |01 | + | |01:49 |
|We can give the path along with the filename | |We can give the path along with the filename | ||
|- | |- | ||
− | | 01 | + | | 01:53 |
| And We can also give the extension. | | And We can also give the extension. | ||
− | |||
|- | |- | ||
− | | 01 | + | | 01:56 |
|Here we can give the mode of the file. | |Here we can give the mode of the file. | ||
|- | |- | ||
− | |01 | + | |01:59 |
|Let us see the types of modes : | |Let us see the types of modes : | ||
+ | |||
|- | |- | ||
− | | 02 | + | | 02:02 |
| w - creates '''file''' for read and write. | | w - creates '''file''' for read and write. | ||
− | |||
|- | |- | ||
− | | 02 | + | | 02:06 |
|r – opens ''' file''' for reading. | |r – opens ''' file''' for reading. | ||
− | |||
|- | |- | ||
− | | 02 | + | | 02:09 |
|a – writing at the end of the '''file. ''' | |a – writing at the end of the '''file. ''' | ||
− | |||
|- | |- | ||
− | | 02 | + | | 02:12 |
|Now come back to our program. | |Now come back to our program. | ||
|- | |- | ||
− | | 02 | + | | 02:15 |
|Here, we create a '''Sample.txt file''' in '''write''' mode. | |Here, we create a '''Sample.txt file''' in '''write''' mode. | ||
− | |||
|- | |- | ||
− | | 02 | + | | 02:20 |
|We can see that the path is given. | |We can see that the path is given. | ||
− | |||
|- | |- | ||
− | | 02 | + | | 02:23 |
|Our file will be created on the '''desktop.''' | |Our file will be created on the '''desktop.''' | ||
|- | |- | ||
− | | 02 | + | | 02:27 |
|Then we will write the statements into the '''file.''' | |Then we will write the statements into the '''file.''' | ||
|- | |- | ||
− | | 02 | + | | 02:30 |
|''' "Welcome to the spoken-tutorial" ''' and | |''' "Welcome to the spoken-tutorial" ''' and | ||
− | |||
|- | |- | ||
− | | 02 | + | | 02:32 |
|''' "This is an test example" ''' | |''' "This is an test example" ''' | ||
− | |||
|- | |- | ||
− | | 02 | + | | 02:34 |
| '''fprintf''' writes output to the given output stream. | | '''fprintf''' writes output to the given output stream. | ||
− | |||
|- | |- | ||
− | | 02 | + | | 02:39 |
| '''fclose '''closes the file associated with the stream. | | '''fclose '''closes the file associated with the stream. | ||
|- | |- | ||
− | | 02 | + | | 02:43 |
|And this is our '''return statement. ''' | |And this is our '''return statement. ''' | ||
|- | |- | ||
− | | 02 | + | | 02:46 |
|Now click on '''Save. ''' | |Now click on '''Save. ''' | ||
|- | |- | ||
− | | 02 | + | | 02:48 |
|Let us execute the program. | |Let us execute the program. | ||
|- | |- | ||
− | | 02 | + | | 02:50 |
|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 | + | | 02:59 |
|To compile, type | |To compile, type | ||
|- | |- | ||
− | | 03 | + | | 03:00 |
|'''gcc space file dot c space hyphen o space file ''' | |'''gcc space file dot c space hyphen o space file ''' | ||
− | |||
|- | |- | ||
− | | 03 | + | | 03:06 |
|Press '''Enter ''' | |Press '''Enter ''' | ||
− | |||
|- | |- | ||
− | | 03 | + | | 03:07 |
|To execute, type '''dot slash'file''' (./file) | |To execute, type '''dot slash'file''' (./file) | ||
− | |||
|- | |- | ||
− | | 03 | + | | 03:11 |
| Press '''Enter''' | | Press '''Enter''' | ||
− | |||
|- | |- | ||
− | | 03 | + | | 03:13 |
|We see the '''file''' is executed. | |We see the '''file''' is executed. | ||
+ | |||
|- | |- | ||
− | | 03 | + | | 03:15 |
|Now we will check it out. | |Now we will check it out. | ||
− | |||
|- | |- | ||
− | | 03 | + | | 03:17 |
|Let us open the '''home folder.''' | |Let us open the '''home folder.''' | ||
|- | |- | ||
− | | 03 | + | | 03:20 |
|Click on the '''home folder''' option. | |Click on the '''home folder''' option. | ||
|- | |- | ||
− | | 03 | + | | 03:22 |
|Now click on the '''Desktop''' option. | |Now click on the '''Desktop''' option. | ||
− | |||
|- | |- | ||
− | | 03 | + | | 03:25 |
|Here is our '''sample.txt''' file. | |Here is our '''sample.txt''' file. | ||
|- | |- | ||
− | | 03 | + | | 03:29 |
|This shows that our file is successfully created. | |This shows that our file is successfully created. | ||
− | |||
|- | |- | ||
− | | 03 | + | | 03:32 |
|Now let us open. | |Now let us open. | ||
|- | |- | ||
− | | 03 | + | | 03:34 |
|Double click on the file. | |Double click on the file. | ||
− | |||
|- | |- | ||
− | | 03 | + | | 03:36 |
|We can see the messages here. | |We can see the messages here. | ||
− | |||
|- | |- | ||
− | | 03 | + | | 03:39 |
|'''Welcome to the Spoken Tutorial. ''' | |'''Welcome to the Spoken Tutorial. ''' | ||
− | |||
|- | |- | ||
− | | 03 | + | | 03:41 |
|'''This is an test example. ''' | |'''This is an test example. ''' | ||
− | |||
|- | |- | ||
− | | 03 | + | | 03:44 |
|This is how we create a file and write data into it. | |This is how we create a file and write data into it. | ||
− | |||
|- | |- | ||
− | | 03 | + | | 03:48 |
|Now we will see how to read data from a '''file. ''' | |Now we will see how to read data from a '''file. ''' | ||
+ | |||
|- | |- | ||
− | | 03 | + | | 03:52 |
| I have already made the program. | | I have already made the program. | ||
|- | |- | ||
− | | 03 | + | | 03:54 |
|I will open it. | |I will open it. | ||
− | |||
− | |||
|- | |- | ||
− | | 03 | + | | 03:56 |
|In this program we will read data from our '''sample.txt''' file and print the data on the console. | |In this program we will read data from our '''sample.txt''' file and print the data on the console. | ||
− | |||
|- | |- | ||
− | | 04 | + | | 04:03 |
|Let me explain the code now. | |Let me explain the code now. | ||
|- | |- | ||
− | | 04 | + | | 04:05 |
|This is our '''header file. ''' | |This is our '''header file. ''' | ||
+ | |||
|- | |- | ||
− | | 04 | + | | 04:08 |
|This is our '''main function. ''' | |This is our '''main function. ''' | ||
+ | |||
|- | |- | ||
− | | 04 | + | | 04:10 |
|Here, a '''file variable''' and a '''pointer''' to the '''file variable''' is defined. | |Here, a '''file variable''' and a '''pointer''' to the '''file variable''' is defined. | ||
|- | |- | ||
− | | 04 | + | | 04:15 |
|Then we have declared a '''character variable c.''' | |Then we have declared a '''character variable c.''' | ||
|- | |- | ||
− | | 04 | + | | 04:19 |
|Here, we open the '''file Sample.txt''' in '''read''' mode. | |Here, we open the '''file Sample.txt''' in '''read''' mode. | ||
|- | |- | ||
− | | 04 | + | | 04:24 |
|The output is stored in '''fp.''' | |The output is stored in '''fp.''' | ||
− | |||
|- | |- | ||
− | | 04 | + | | 04:27 |
|Then we check the condition. | |Then we check the condition. | ||
|- | |- | ||
− | | 04 | + | | 04:29 |
|If '''fp''' is equals to '''NULL. ''' | |If '''fp''' is equals to '''NULL. ''' | ||
− | |||
|- | |- | ||
− | | 04 | + | | 04:32 |
|If the condition is '''true,''' then we print the message: | |If the condition is '''true,''' then we print the message: | ||
− | |||
|- | |- | ||
− | | 04 | + | | 04:36 |
|''' "File doesn't exist." ''' | |''' "File doesn't exist." ''' | ||
− | |||
|- | |- | ||
− | | 04 | + | | 04:38 |
|Else it will check for another condition. | |Else it will check for another condition. | ||
|- | |- | ||
− | | 04 | + | | 04:41 |
|'''While c is not equal to EOF. ''' | |'''While c is not equal to EOF. ''' | ||
− | |||
|- | |- | ||
− | | 04 | + | | 04:46 |
|Here, '''EOF''' is the '''end of file. ''' | |Here, '''EOF''' is the '''end of file. ''' | ||
− | |||
|- | |- | ||
− | | 04 | + | | 04:49 |
|It denotes the end of input. | |It denotes the end of input. | ||
− | |||
|- | |- | ||
− | | 04 | + | | 04:52 |
|It is a condition where no more data can be read from a data source. | |It is a condition where no more data can be read from a data source. | ||
− | |||
|- | |- | ||
− | | 04 | + | | 04:57 |
|If the condition is true, then it will display the characters from '''Sample.txt''' file, on the console. | |If the condition is true, then it will display the characters from '''Sample.txt''' file, on the console. | ||
|- | |- | ||
− | | 05 | + | | 05:06 |
|Here, '''getc''' returns a '''character''' from a specified file or stream. | |Here, '''getc''' returns a '''character''' from a specified file or stream. | ||
|- | |- | ||
− | | 05 | + | | 05:12 |
|Now, it will return a '''character''' from our '''Sample.txt''' file. | |Now, it will return a '''character''' from our '''Sample.txt''' file. | ||
− | |||
|- | |- | ||
− | | 05 | + | | 05:17 |
|'''putchar''' is used to display a '''character''' on the '''console. ''' | |'''putchar''' is used to display a '''character''' on the '''console. ''' | ||
|- | |- | ||
− | | 05 | + | | 05:22 |
|Then it will store the '''characters''' in variable c. | |Then it will store the '''characters''' in variable c. | ||
− | |||
|- | |- | ||
− | | 05 | + | | 05:25 |
|Here we close the file. | |Here we close the file. | ||
|- | |- | ||
− | | 05 | + | | 05:28 |
|And this is our '''return statement. ''' | |And this is our '''return statement. ''' | ||
|- | |- | ||
− | | 05 | + | | 05:30 |
|Now click on '''Save. ''' | |Now click on '''Save. ''' | ||
|- | |- | ||
− | | 05 | + | | 05:32 |
|Let us execute the program. | |Let us execute the program. | ||
|- | |- | ||
− | | 05 | + | | 05:35 |
|Come back to the '''terminal. ''' | |Come back to the '''terminal. ''' | ||
|- | |- | ||
− | | 05 | + | | 05:37 |
|To compile, type | |To compile, type | ||
|- | |- | ||
− | | 05 | + | | 05:38 |
|'''gcc space readfile dot c space hyphen o space read ''' | |'''gcc space readfile dot c space hyphen o space read ''' | ||
− | |||
|- | |- | ||
− | | 05 | + | | 05:45 |
|Now press '''Enter ''' | |Now press '''Enter ''' | ||
|- | |- | ||
− | | 05 | + | | 05:47 |
|To execute, type '''./read ''' | |To execute, type '''./read ''' | ||
|- | |- | ||
− | | 05 | + | | 05:52 |
|The output is displayed as: | |The output is displayed as: | ||
|- | |- | ||
− | | 05 | + | | 05:54 |
|'''Welcome to the Spoken-Tutorial. ''' | |'''Welcome to the Spoken-Tutorial. ''' | ||
|- | |- | ||
− | | 05 | + | | 05:56 |
|'''This is an test example. ''' | |'''This is an test example. ''' | ||
|- | |- | ||
− | | 05 | + | | 05:59 |
|This brings us to the end of this tutorial. | |This brings us to the end of this tutorial. | ||
|- | |- | ||
− | | 06 | + | | 06:01 |
|Come back to our slides. | |Come back to our slides. | ||
|- | |- | ||
− | | 06 | + | | 06:03 |
|Let us summarize. | |Let us summarize. | ||
|- | |- | ||
− | | 06 | + | | 06:04 |
|In this tutorial we learnt, | |In this tutorial we learnt, | ||
− | |||
|- | |- | ||
− | | 06 | + | | 06:06 |
|File handling. | |File handling. | ||
− | |||
|- | |- | ||
− | | 06 | + | | 06:08 |
|To write data into a file. | |To write data into a file. | ||
|- | |- | ||
− | | 06 | + | | 06:10 |
|eg.''' fp = fopen(“Sample.txt”, “w”); ''' | |eg.''' fp = fopen(“Sample.txt”, “w”); ''' | ||
− | |||
|- | |- | ||
− | | 06 | + | | 06:17 |
|To read data from a file. | |To read data from a file. | ||
|- | |- | ||
− | | 06 | + | | 06:18 |
|eg.''' fp = fopen(“Sample.txt”, “r”); ''' | |eg.''' fp = fopen(“Sample.txt”, “r”); ''' | ||
− | |||
|- | |- | ||
− | | 06 | + | | 06:25 |
|As an assignment, | |As an assignment, | ||
|- | |- | ||
− | | 06 | + | | 06:26 |
|Write a program to create a file '''TEST. ''' | |Write a program to create a file '''TEST. ''' | ||
|- | |- | ||
− | | 06 | + | | 06:30 |
|Write your name and address in the file '''TEST. ''' | |Write your name and address in the file '''TEST. ''' | ||
|- | |- | ||
− | | 06 | + | | 06:33 |
|Then display it on the console using C Program | |Then display it on the console using C Program | ||
|- | |- | ||
− | | 06 | + | | 06:37 |
|Watch the video available at the link shown below | |Watch the video available at the link shown below | ||
|- | |- | ||
− | | 06 | + | | 06:40 |
|It summarizes the Spoken Tutorial project | |It summarizes the Spoken Tutorial project | ||
|- | |- | ||
− | | 06 | + | | 06:43 |
|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 | + | | 06:47 |
|The Spoken Tutorial Project Team | |The Spoken Tutorial Project Team | ||
|- | |- | ||
− | | 06 | + | | 06:50 |
|Conducts workshops using spoken tutorials | |Conducts workshops using spoken tutorials | ||
|- | |- | ||
− | |06 | + | |06:53 |
|Gives certificates to those who pass an online test | |Gives certificates to those who pass an online test | ||
|- | |- | ||
− | | 06 | + | | 06:57 |
|For more details, please write to, contact@spoken-tutorial.org | |For more details, please write to, contact@spoken-tutorial.org | ||
|- | |- | ||
− | | 07 | + | | 07:03 |
|Spoken Tutorial Project is a part of Talk to a Teacher project | |Spoken Tutorial Project is a part of Talk to a Teacher project | ||
|- | |- | ||
− | | 07 | + | | 07:07 |
|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 | + | | 07:14 |
|More information on this Mission is available at the link shown below | |More information on this Mission is available at the link shown below | ||
|- | |- | ||
− | | 07 | + | | 07:18 |
| This is Ashwini Patil from IIT Bombay signing off | | This is Ashwini Patil from IIT Bombay signing off | ||
|- | |- | ||
− | | 07 | + | | 07:22 |
|Thank You for joining. | |Thank You for joining. |
Revision as of 16:03, 23 June 2014
Time | Narration |
00:01 | Welcome to the spoken-tutorial on files in C. |
00:05 | In this tutorial we will learn how, |
00:08 | To open a file. |
00:10 | How to read data from a file. |
00:12 | How to write data into a file. |
00:15 | Few examples. |
00:17 | To record this tutorial, I am using, |
00:20 | Ubuntu Operating System version 11.10, |
00:24 | gcc Compiler version 4.6.1. |
00:28 | Let us start with the introduction to files. |
00:31 | File is a collection of data. |
00:34 | It can be a database, a program, a letter or anything. |
00:39 | We can create a file and access it using C. |
00:44 | Now let us see an example on file handling in C. |
00:48 | I have a written program. |
00:50 | Let's take a look. |
00:51 | Note that our filename is file.c |
00:55 | In this program we will create a file and write data into it. |
01:01 | Let me explain the code now |
01:03 | This is our header file. |
01:05 | This is our main function. |
01:07 | To define a file variable we use the type FILE. |
01:12 | The FILE variable is defined under the header stdio.h |
01:19 | *fp is a pointer to the FILE variable. |
01:22 | It will store all the information about the file. |
01:26 | Like its name, status and current information. |
01:31 | Let us go back to our slides. |
01:33 | Now we will see the syntax to open a file. |
01:37 | Here, the fopen function opens a stream. |
01:42 | Then it links the file with the stream. |
01:44 | filename is the name of the file that we want to open or create. |
01:49 | We can give the path along with the filename
|
01:53 | And We can also give the extension. |
01:56 | Here we can give the mode of the file. |
01:59 | Let us see the types of modes : |
02:02 | w - creates file for read and write. |
02:06 | r – opens file for reading. |
02:09 | a – writing at the end of the file. |
02:12 | Now come back to our program. |
02:15 | Here, we create a Sample.txt file in write mode. |
02:20 | We can see that the path is given. |
02:23 | Our file will be created on the desktop.
|
02:27 | Then we will write the statements into the file. |
02:30 | "Welcome to the spoken-tutorial" and |
02:32 | "This is an test example" |
02:34 | fprintf writes output to the given output stream. |
02:39 | fclose closes the file associated with the stream. |
02:43 | And this is our return statement. |
02:46 | Now click on Save. |
02:48 | Let us execute the program. |
02:50 | Open the terminal window by pressing Ctrl, Alt and T keys simultaneously on your keyboard |
02:59 | To compile, type |
03:00 | gcc space file dot c space hyphen o space file |
03:06 | Press Enter |
03:07 | To execute, type dot slash'file (./file) |
03:11 | Press Enter |
03:13 | We see the file is executed. |
03:15 | Now we will check it out. |
03:17 | Let us open the home folder. |
03:20 | Click on the home folder option.
|
03:22 | Now click on the Desktop option. |
03:25 | Here is our sample.txt file. |
03:29 | This shows that our file is successfully created. |
03:32 | Now let us open. |
03:34 | Double click on the file. |
03:36 | We can see the messages here. |
03:39 | Welcome to the Spoken Tutorial. |
03:41 | This is an test example. |
03:44 | This is how we create a file and write data into it. |
03:48 | Now we will see how to read data from a file. |
03:52 | I have already made the program. |
03:54 | I will open it. |
03:56 | In this program we will read data from our sample.txt file and print the data on the console. |
04:03 | Let me explain the code now. |
04:05 | This is our header file. |
04:08 | This is our main function. |
04:10 | Here, a file variable and a pointer to the file variable is defined. |
04:15 | Then we have declared a character variable c. |
04:19 | Here, we open the file Sample.txt in read mode. |
04:24 | The output is stored in fp. |
04:27 | Then we check the condition. |
04:29 | If fp is equals to NULL. |
04:32 | If the condition is true, then we print the message: |
04:36 | "File doesn't exist." |
04:38 | Else it will check for another condition. |
04:41 | While c is not equal to EOF. |
04:46 | Here, EOF is the end of file. |
04:49 | It denotes the end of input. |
04:52 | It is a condition where no more data can be read from a data source. |
04:57 | If the condition is true, then it will display the characters from Sample.txt file, on the console. |
05:06 | Here, getc returns a character from a specified file or stream. |
05:12 | Now, it will return a character from our Sample.txt file. |
05:17 | putchar is used to display a character on the console. |
05:22 | Then it will store the characters in variable c. |
05:25 | Here we close the file. |
05:28 | And this is our return statement. |
05:30 | Now click on Save. |
05:32 | Let us execute the program. |
05:35 | Come back to the terminal. |
05:37 | To compile, type |
05:38 | gcc space readfile dot c space hyphen o space read |
05:45 | Now press Enter
|
05:47 | To execute, type ./read |
05:52 | The output is displayed as: |
05:54 | Welcome to the Spoken-Tutorial.
|
05:56 | This is an test example.
|
05:59 | This brings us to the end of this tutorial. |
06:01 | Come back to our slides. |
06:03 | Let us summarize. |
06:04 | In this tutorial we learnt, |
06:06 | File handling. |
06:08 | To write data into a file. |
06:10 | eg. fp = fopen(“Sample.txt”, “w”); |
06:17 | To read data from a file.
|
06:18 | eg. fp = fopen(“Sample.txt”, “r”); |
06:25 | As an assignment, |
06:26 | Write a program to create a file TEST.
|
06:30 | Write your name and address in the file TEST. |
06:33 | Then display it on the console using C Program |
06:37 | Watch the video available at the link shown below |
06:40 | It summarizes the Spoken Tutorial project |
06:43 | If you do not have good bandwidth, you can download and watch it |
06:47 | The Spoken Tutorial Project Team |
06:50 | Conducts workshops using spoken tutorials |
06:53 | Gives certificates to those who pass an online test |
06:57 | For more details, please write to, contact@spoken-tutorial.org |
07:03 | Spoken Tutorial Project is a part of Talk to a Teacher project |
07:07 | It is supported by the National Mission on Education through ICT, MHRD, Government of India |
07:14 | More information on this Mission is available at the link shown below |
07:18 | This is Ashwini Patil from IIT Bombay signing off |
07:22 | Thank You for joining. |