SlideShare une entreprise Scribd logo
1  sur  10
From ArguSacademy
EXTRA
EXTRA
EXTRA
#include<stdio.h> 
void main() 
{ 
char ch; 
FILE *fptr; 
fptr =fopen("c:myfile.txt","a"); 
printf("Enter the data to be stored in a filen"); 
while((ch=getchar())!=EOF) 
{ 
fputc(ch,fptr); 
} 
fclose(fptr); 
fptr=fopen("c:myfile.text","r"); 
while((ch=fgetc(fptr))!=EOF) 
{ 
printf("%c",ch); 
} 
fclose(fptr); 
} 
EXTRA
EXTRA
#include<stdio.h> 
void main() 
{ 
char ch; 
FILE *fp; 
fp=fopen("sample.txt","w"); 
printf("Input a character::n"); 
while((ch=fgetc(stdin))!=EOF) 
{ 
fputc(ch,fp); 
} 
fclose(fp); 
fp=fopen("sample.txt","r"); 
while((ch=fgetc(fp))!=EOF) 
printf("%c",ch); 
} 
EXTRA
EXTRA
EXTRA
#include<conio.h> 
void main() 
{ 
FILE *fp; 
char s[100]; 
fp=fopen("text.txt","w"); 
if(fp==NULL) 
{ 
puts("cannot open a file"); 
exit(1); 
} 
printf("Enter a text (type end to stop):n"); 
while(strcmp(gets(s),"end")!=0) 
{ 
fputs(s,fp); 
} 
fclose(fp); 
fp=fopen("text.txt","r"); 
if(fgets(s,10,fp)!=NULL) 
{ 
printf("%s",s); 
} 
} 
EXTRA

Contenu connexe

Tendances

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
Muhammed Thanveer M
 

Tendances (20)

File in C Programming
File in C ProgrammingFile in C Programming
File in C Programming
 
File handling in c
File  handling in cFile  handling in c
File handling in c
 
File Management
File ManagementFile Management
File Management
 
File handling in C
File handling in CFile handling in C
File handling in C
 
File in C language
File in C languageFile in C language
File in C language
 
File handling-c
File handling-cFile handling-c
File handling-c
 
File handling in c
File handling in cFile handling in c
File handling in c
 
C Programming Unit-5
C Programming Unit-5C Programming Unit-5
C Programming Unit-5
 
File handling-dutt
File handling-duttFile handling-dutt
File handling-dutt
 
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
 
File handling-c programming language
File handling-c programming languageFile handling-c programming language
File handling-c programming language
 
file
filefile
file
 
File handling in C by Faixan
File handling in C by FaixanFile handling in C by Faixan
File handling in C by Faixan
 
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
 
Lecture 20 - File Handling
Lecture 20 - File HandlingLecture 20 - File Handling
Lecture 20 - File Handling
 
File Management in C
File Management in CFile Management in C
File Management in C
 
Unit5
Unit5Unit5
Unit5
 
file management in c language
file management in c languagefile management in c language
file management in c language
 
File Handling in C
File Handling in C File Handling in C
File Handling in C
 

En vedette (20)

VISUAL BASIC .net iv
VISUAL BASIC .net ivVISUAL BASIC .net iv
VISUAL BASIC .net iv
 
Computer development
Computer developmentComputer development
Computer development
 
Multimedia basic
Multimedia basicMultimedia basic
Multimedia basic
 
Php opps
Php oppsPhp opps
Php opps
 
TALLY 1 st level entry
TALLY 1 st level entryTALLY 1 st level entry
TALLY 1 st level entry
 
TALLY Pos ENTRY
TALLY Pos ENTRYTALLY Pos ENTRY
TALLY Pos ENTRY
 
Application software
Application softwareApplication software
Application software
 
VISUAL BASIC .net iii
VISUAL BASIC .net iiiVISUAL BASIC .net iii
VISUAL BASIC .net iii
 
Php basic
Php basicPhp basic
Php basic
 
Java script
Java scriptJava script
Java script
 
TALLY Payroll ENTRY
TALLY Payroll ENTRYTALLY Payroll ENTRY
TALLY Payroll ENTRY
 
TALLY Service tax & tds ENTRY
TALLY Service tax & tds ENTRYTALLY Service tax & tds ENTRY
TALLY Service tax & tds ENTRY
 
Paint
PaintPaint
Paint
 
C programming flow of controls
C  programming flow of controlsC  programming flow of controls
C programming flow of controls
 
Php oops1
Php oops1Php oops1
Php oops1
 
COMPUTER Tips ‘n’ Tricks
COMPUTER Tips ‘n’   TricksCOMPUTER Tips ‘n’   Tricks
COMPUTER Tips ‘n’ Tricks
 
1 tally basic
1 tally basic1 tally basic
1 tally basic
 
Groups
GroupsGroups
Groups
 
VISUAL BASIC .net ii
VISUAL BASIC .net iiVISUAL BASIC .net ii
VISUAL BASIC .net ii
 
Virus examples
Virus examplesVirus examples
Virus examples
 

Similaire à C programming file handling

C basics
C basicsC basics
C basics
MSc CST
 
10〜30分で何となく分かるGo
10〜30分で何となく分かるGo10〜30分で何となく分かるGo
10〜30分で何となく分かるGo
Moriyoshi Koizumi
 
C-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdfC-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdf
herminaherman
 

Similaire à C programming file handling (20)

Data structures
Data structuresData structures
Data structures
 
Vcs26
Vcs26Vcs26
Vcs26
 
File handling in c language
File handling in c languageFile handling in c language
File handling in c language
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
14. fiile io
14. fiile io14. fiile io
14. fiile io
 
C Language Lecture 22
C Language Lecture 22C Language Lecture 22
C Language Lecture 22
 
L8 file
L8 fileL8 file
L8 file
 
Files
FilesFiles
Files
 
C programms
C programmsC programms
C programms
 
Ch8 file processing
Ch8 file processingCh8 file processing
Ch8 file processing
 
C basics
C basicsC basics
C basics
 
week-12x
week-12xweek-12x
week-12x
 
Data Structure Using C - FILES
Data Structure Using C - FILESData Structure Using C - FILES
Data Structure Using C - FILES
 
10〜30分で何となく分かるGo
10〜30分で何となく分かるGo10〜30分で何となく分かるGo
10〜30分で何となく分かるGo
 
C-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdfC-Program Custom Library, Header File, and Implementation FilesI .pdf
C-Program Custom Library, Header File, and Implementation FilesI .pdf
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
PPS Notes Unit 5.pdf
PPS Notes Unit 5.pdfPPS Notes Unit 5.pdf
PPS Notes Unit 5.pdf
 
File handling(some slides only)
File handling(some slides only)File handling(some slides only)
File handling(some slides only)
 
Institute management
Institute managementInstitute management
Institute management
 
Ch3(working with file)
Ch3(working with file)Ch3(working with file)
Ch3(working with file)
 

Plus de argusacademy (20)

Css & dhtml
Css  & dhtmlCss  & dhtml
Css & dhtml
 
Html table
Html tableHtml table
Html table
 
Html ordered & unordered list
Html ordered & unordered listHtml ordered & unordered list
Html ordered & unordered list
 
Html level ii
Html level  iiHtml level  ii
Html level ii
 
Html frame
Html frameHtml frame
Html frame
 
Html forms
Html formsHtml forms
Html forms
 
Html creating page link or hyperlink
Html creating page link or hyperlinkHtml creating page link or hyperlink
Html creating page link or hyperlink
 
Html basic
Html basicHtml basic
Html basic
 
Php string
Php stringPhp string
Php string
 
Php session
Php sessionPhp session
Php session
 
Php if else
Php if elsePhp if else
Php if else
 
Php creating forms
Php creating formsPhp creating forms
Php creating forms
 
Php create and invoke function
Php create and invoke functionPhp create and invoke function
Php create and invoke function
 
Php array
Php arrayPhp array
Php array
 
Sql query
Sql querySql query
Sql query
 
Rdbms
RdbmsRdbms
Rdbms
 
Oracle
OracleOracle
Oracle
 
Vb.net iv
Vb.net ivVb.net iv
Vb.net iv
 
Vb.net iii
Vb.net iiiVb.net iii
Vb.net iii
 
Vb.net ii
Vb.net iiVb.net ii
Vb.net ii
 

Dernier

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Dernier (20)

Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 

C programming file handling

  • 5. #include<stdio.h> void main() { char ch; FILE *fptr; fptr =fopen("c:myfile.txt","a"); printf("Enter the data to be stored in a filen"); while((ch=getchar())!=EOF) { fputc(ch,fptr); } fclose(fptr); fptr=fopen("c:myfile.text","r"); while((ch=fgetc(fptr))!=EOF) { printf("%c",ch); } fclose(fptr); } EXTRA
  • 7. #include<stdio.h> void main() { char ch; FILE *fp; fp=fopen("sample.txt","w"); printf("Input a character::n"); while((ch=fgetc(stdin))!=EOF) { fputc(ch,fp); } fclose(fp); fp=fopen("sample.txt","r"); while((ch=fgetc(fp))!=EOF) printf("%c",ch); } EXTRA
  • 10. #include<conio.h> void main() { FILE *fp; char s[100]; fp=fopen("text.txt","w"); if(fp==NULL) { puts("cannot open a file"); exit(1); } printf("Enter a text (type end to stop):n"); while(strcmp(gets(s),"end")!=0) { fputs(s,fp); } fclose(fp); fp=fopen("text.txt","r"); if(fgets(s,10,fp)!=NULL) { printf("%s",s); } } EXTRA