SlideShare a Scribd company logo
1 of 28
Recall
• What are the difference between stack
and heap?
• How to allocate memory in stack? And
heap?
• What are the difference between malloc()
and calloc()
Introduction to C
File handling in C
Week 3- day 2
Relevance of File handling in C
Relevance of File handling in C
Instruction Address
11011110 00110000
00010010 00110001
10000000 00001010
01001000 10000001
00001100 10000100
11000001 00101011
01011011 01011001
11101011 11111000
Mother Board
Ram
Loads instruction for execution
CPU
Ram Stores data
whenever the power is
on
Instruction Address
Ram
Loads instruction for execution
CPU
Mother Board
Relevance of File handling in C
Ram looses all data
whenever the power is OFF
as it is volatile. So we need a
mechanism to store data
permanently
Instruction Address
Ram
Loads instruction for execution
CPU
Mother Board
Relevance of File handling in C
Keeps all data in a File
and stores it on
secondary disks such
as hard disk, CD etc
You Should know !
Whenever we open a
file it will be loaded
into RAM memory .
Instruction Address
11011110 00110000
00010010 00110001
10000000 00001010
01001000 10000001
00001100 10000100
11000001 00101011
01011011 01011001
11101011 11111000
Mother Board
Ram
Loads instruction for execution
CPU
File Handling
• Files are created for permanent
storage of data
• When a computer reads a file, it
copies the file from the storage device
to memory; when it writes to a file, it
transfers data from memory to the
storage device.
Sample Program
File Handling
FILE *p;
*p=fopen(“data.txt”,”w”)
fprintf(p,“hello World”);
fclose(); First you need a File
pointer to the memory
location where the file is
loaded
File Handling
FILE *p;
*p=fopen(“data.txt”,”w”)
fprintf(p,“hello World”);
fclose();
Fopen() opens the file in
different modes and
returns the address
File Handling
FILE *p;
*p=fopen(“data.txt”,”w”)
fprintf(p,“hello World”);
fclose(); fprintf() is used to write in
to a file same like we use
printf to write on the
screen
File Handling
FILE *p;
*p=fopen(“data.txt”,”r”)
fprintf(p,“hello World”);
fclose(p);
File must be closed at the
end of program using
inbuilt function fclose()
File Modes
• r : reads from a file
• w : overwrite to a file
• a : append on a file
• r+ : reads and writes. File
pointer at the beginning
• w+ : reads and overwrites.
• a+ : reads and appends .File
pointer at the beginning
Write to file
• fprintf(p,” hello %s”,name);
• // same like printf() writes characters into a
file
• fputs(“message”,p);
• // same purpose of fprintf()
• fputc(„h‟,p);
• // writes a single character into file
Read from File
• fscanf(p,”%s”,message);
• // same like scanf() reads characters from
file and assign to a variable
• fgets(message,100,p);
• // same purpose of fscanf() but can mention
the number of characters to be read
• fgetc(p);
• // returns the current character and
advance the file pointer once; returns EOF
when file ending has reached
#include <stdio.h>
void main ()
{
FILE *fp;
int c,n=0;
fp = fopen("file.txt","r");
if(fp == NULL)
{
printf("Error in opening file");
Exit(0);
}
do
{
c = fgetc(fp);// fgetc() always return integer .if it is character it returns corresponding integer
printf("%c", c);
}
while(c != EOF);
fclose(fp);
}
Questions?
“A good question deserve a good
grade…”
Self Check !!
Self Check
• The first and second arguments of fopen
are
a) A character string containing the name of the file &
the second argument is the mode.
b) A character string containing the name of the user &
the second argument is the mode.
c) A character string containing file poniter & the
second argument is the mode.
d) None of the mentioned of the mentioned
Self Check
• The first and second arguments of fopen
are
a) A character string containing the name of the file &
the second argument is the mode.
b) A character string containing the name of the user &
the second argument is the mode.
c) A character string containing file poniter & the
second argument is the mode.
d) None of the mentioned of the mentioned
Self Check
• If there is any error while opening a file, fopen
will return
a) Nothing
b) EOF
c) NULL
d) Depends on compiler
Self Check
• If there is any error while opening a file, fopen
will return
a) Nothing
b) EOF
c) NULL
d) Depends on compiler
Self Check
• FILE is of type ______ ?
a) int type
b) char * type
c) struct type
d) None of the mentioned
Self Check
• FILE is of type ______ ?
a) int type
b) char * type
c) struct type
d) None of the mentioned
Self Check
• Which of the following mode argument is used
to truncate?
a) a
b) f
c) w
d) t
Self Check
• Which of the following mode argument is used
to truncate?
a) a
b) f
c) w
d) t
End of Day 2

More Related Content

What's hot (20)

File in C Programming
File in C ProgrammingFile in C Programming
File in C Programming
 
Files in c
Files in cFiles in c
Files in c
 
File handling in C
File handling in CFile handling in C
File handling in C
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Understanding c file handling functions with examples
Understanding c file handling functions with examplesUnderstanding c file handling functions with examples
Understanding c file handling functions with examples
 
C Programming Unit-5
C Programming Unit-5C Programming Unit-5
C Programming Unit-5
 
File in c
File in cFile in c
File in c
 
File handling in c
File handling in cFile handling in c
File handling in c
 
File operations in c
File operations in cFile operations in c
File operations in c
 
File Handling and Command Line Arguments in C
File Handling and Command Line Arguments in CFile Handling and Command Line Arguments in C
File Handling and Command Line Arguments in C
 
1file handling
1file handling1file handling
1file handling
 
File handling-c programming language
File handling-c programming languageFile handling-c programming language
File handling-c programming language
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Python-files
Python-filesPython-files
Python-files
 
File handling in c
File  handling in cFile  handling in c
File handling in c
 
7.0 files and c input
7.0 files and c input7.0 files and c input
7.0 files and c input
 
File handling in 'C'
File handling in 'C'File handling in 'C'
File handling in 'C'
 
File Handling in C
File Handling in C File Handling in C
File Handling in C
 
Module 03 File Handling in C
Module 03 File Handling in CModule 03 File Handling in C
Module 03 File Handling in C
 
File handling in c
File handling in c File handling in c
File handling in c
 

Viewers also liked (12)

Introduction to mysql part 5
Introduction to mysql part 5Introduction to mysql part 5
Introduction to mysql part 5
 
How to get a job in it?
How to get a job in it?How to get a job in it?
How to get a job in it?
 
Code optimization
Code optimization Code optimization
Code optimization
 
Different dimensions of android development baabtra.com
Different dimensions of android development baabtra.comDifferent dimensions of android development baabtra.com
Different dimensions of android development baabtra.com
 
scope of variables
scope of variablesscope of variables
scope of variables
 
Functions with heap and stack
Functions with heap and stackFunctions with heap and stack
Functions with heap and stack
 
Mvc
MvcMvc
Mvc
 
C# loops
C# loopsC# loops
C# loops
 
Error handling in ASP.NET
Error handling in ASP.NETError handling in ASP.NET
Error handling in ASP.NET
 
Transaction
TransactionTransaction
Transaction
 
Dom
DomDom
Dom
 
Intoduction to php strings
Intoduction to php  stringsIntoduction to php  strings
Intoduction to php strings
 

Similar to Introduction to c part 4

Similar to Introduction to c part 4 (20)

File management
File managementFile management
File management
 
File mangement
File mangementFile mangement
File mangement
 
filehandling.pptx
filehandling.pptxfilehandling.pptx
filehandling.pptx
 
File handling With Solve Programs
File handling With Solve ProgramsFile handling With Solve Programs
File handling With Solve Programs
 
VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5VIT351 Software Development VI Unit5
VIT351 Software Development VI Unit5
 
file_c.pdf
file_c.pdffile_c.pdf
file_c.pdf
 
File management
File managementFile management
File management
 
EASY UNDERSTANDING OF FILES IN C LANGUAGE.pdf
EASY UNDERSTANDING OF FILES IN C LANGUAGE.pdfEASY UNDERSTANDING OF FILES IN C LANGUAGE.pdf
EASY UNDERSTANDING OF FILES IN C LANGUAGE.pdf
 
File handing in C
File handing in CFile handing in C
File handing in C
 
File management
File managementFile management
File management
 
637225560972186380.pdf
637225560972186380.pdf637225560972186380.pdf
637225560972186380.pdf
 
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDYC UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
 
Filehadnling
FilehadnlingFilehadnling
Filehadnling
 
Unit5
Unit5Unit5
Unit5
 
File Handling in C Programming
File Handling in C ProgrammingFile Handling in C Programming
File Handling in C Programming
 
File Management in C
File Management in CFile Management in C
File Management in C
 
Data file handling
Data file handlingData file handling
Data file handling
 
PPS PPT 2.pptx
PPS PPT 2.pptxPPS PPT 2.pptx
PPS PPT 2.pptx
 
File Handling in C
File Handling in CFile Handling in C
File Handling in C
 
File Handling
File HandlingFile Handling
File Handling
 

More from baabtra.com - No. 1 supplier of quality freshers

More from baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Recently uploaded

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 

Recently uploaded (20)

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 

Introduction to c part 4

  • 1. Recall • What are the difference between stack and heap? • How to allocate memory in stack? And heap? • What are the difference between malloc() and calloc()
  • 2. Introduction to C File handling in C Week 3- day 2
  • 3. Relevance of File handling in C
  • 4. Relevance of File handling in C Instruction Address 11011110 00110000 00010010 00110001 10000000 00001010 01001000 10000001 00001100 10000100 11000001 00101011 01011011 01011001 11101011 11111000 Mother Board Ram Loads instruction for execution CPU Ram Stores data whenever the power is on
  • 5. Instruction Address Ram Loads instruction for execution CPU Mother Board Relevance of File handling in C Ram looses all data whenever the power is OFF as it is volatile. So we need a mechanism to store data permanently
  • 6. Instruction Address Ram Loads instruction for execution CPU Mother Board Relevance of File handling in C Keeps all data in a File and stores it on secondary disks such as hard disk, CD etc
  • 7. You Should know ! Whenever we open a file it will be loaded into RAM memory . Instruction Address 11011110 00110000 00010010 00110001 10000000 00001010 01001000 10000001 00001100 10000100 11000001 00101011 01011011 01011001 11101011 11111000 Mother Board Ram Loads instruction for execution CPU
  • 8. File Handling • Files are created for permanent storage of data • When a computer reads a file, it copies the file from the storage device to memory; when it writes to a file, it transfers data from memory to the storage device.
  • 10. File Handling FILE *p; *p=fopen(“data.txt”,”w”) fprintf(p,“hello World”); fclose(); First you need a File pointer to the memory location where the file is loaded
  • 11. File Handling FILE *p; *p=fopen(“data.txt”,”w”) fprintf(p,“hello World”); fclose(); Fopen() opens the file in different modes and returns the address
  • 12. File Handling FILE *p; *p=fopen(“data.txt”,”w”) fprintf(p,“hello World”); fclose(); fprintf() is used to write in to a file same like we use printf to write on the screen
  • 13. File Handling FILE *p; *p=fopen(“data.txt”,”r”) fprintf(p,“hello World”); fclose(p); File must be closed at the end of program using inbuilt function fclose()
  • 14. File Modes • r : reads from a file • w : overwrite to a file • a : append on a file • r+ : reads and writes. File pointer at the beginning • w+ : reads and overwrites. • a+ : reads and appends .File pointer at the beginning
  • 15. Write to file • fprintf(p,” hello %s”,name); • // same like printf() writes characters into a file • fputs(“message”,p); • // same purpose of fprintf() • fputc(„h‟,p); • // writes a single character into file
  • 16. Read from File • fscanf(p,”%s”,message); • // same like scanf() reads characters from file and assign to a variable • fgets(message,100,p); • // same purpose of fscanf() but can mention the number of characters to be read • fgetc(p); • // returns the current character and advance the file pointer once; returns EOF when file ending has reached
  • 17. #include <stdio.h> void main () { FILE *fp; int c,n=0; fp = fopen("file.txt","r"); if(fp == NULL) { printf("Error in opening file"); Exit(0); } do { c = fgetc(fp);// fgetc() always return integer .if it is character it returns corresponding integer printf("%c", c); } while(c != EOF); fclose(fp); }
  • 18. Questions? “A good question deserve a good grade…”
  • 20. Self Check • The first and second arguments of fopen are a) A character string containing the name of the file & the second argument is the mode. b) A character string containing the name of the user & the second argument is the mode. c) A character string containing file poniter & the second argument is the mode. d) None of the mentioned of the mentioned
  • 21. Self Check • The first and second arguments of fopen are a) A character string containing the name of the file & the second argument is the mode. b) A character string containing the name of the user & the second argument is the mode. c) A character string containing file poniter & the second argument is the mode. d) None of the mentioned of the mentioned
  • 22. Self Check • If there is any error while opening a file, fopen will return a) Nothing b) EOF c) NULL d) Depends on compiler
  • 23. Self Check • If there is any error while opening a file, fopen will return a) Nothing b) EOF c) NULL d) Depends on compiler
  • 24. Self Check • FILE is of type ______ ? a) int type b) char * type c) struct type d) None of the mentioned
  • 25. Self Check • FILE is of type ______ ? a) int type b) char * type c) struct type d) None of the mentioned
  • 26. Self Check • Which of the following mode argument is used to truncate? a) a b) f c) w d) t
  • 27. Self Check • Which of the following mode argument is used to truncate? a) a b) f c) w d) t