SlideShare a Scribd company logo
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

More Related Content

PDF
Module 03 File Handling in C
PPTX
File handling in c
PPT
File handling in 'C'
PPT
File in c
PPT
File handling in c
PPTX
File Management in C
PPTX
File handling in C
Module 03 File Handling in C
File handling in c
File handling in 'C'
File in c
File handling in c
File Management in C
File handling in C

What's hot (20)

PPT
File in C Programming
PPT
File handling in c
PPT
File Management
PPTX
File handling in C
PPTX
File in C language
PPT
PPTX
C Programming Unit-5
PPT
File handling-dutt
DOCX
Understanding c file handling functions with examples
PPT
File handling-c programming language
PPT
file
PPTX
File handling in C by Faixan
PPT
File handling in c
PPTX
File handling in c
PPT
Lecture 20 - File Handling
PPTX
File Management in C
PPT
Unit5
PPTX
file management in c language
PPTX
File Handling in C
File in C Programming
File handling in c
File Management
File handling in C
File in C language
C Programming Unit-5
File handling-dutt
Understanding c file handling functions with examples
File handling-c programming language
file
File handling in C by Faixan
File handling in c
File handling in c
Lecture 20 - File Handling
File Management in C
Unit5
file management in c language
File Handling in C
Ad

Viewers also liked (20)

PPSX
VISUAL BASIC .net iv
PPSX
Computer development
PPSX
Multimedia basic
PPSX
Php opps
PPSX
TALLY 1 st level entry
PPSX
TALLY Pos ENTRY
PPSX
Application software
PPSX
VISUAL BASIC .net iii
PPSX
Php basic
PPSX
Java script
PPSX
TALLY Payroll ENTRY
PPSX
TALLY Service tax & tds ENTRY
PPSX
PPSX
C programming flow of controls
PPSX
Php oops1
PPSX
COMPUTER Tips ‘n’ Tricks
PPSX
1 tally basic
PPSX
Groups
PPSX
VISUAL BASIC .net ii
PPSX
Virus examples
VISUAL BASIC .net iv
Computer development
Multimedia basic
Php opps
TALLY 1 st level entry
TALLY Pos ENTRY
Application software
VISUAL BASIC .net iii
Php basic
Java script
TALLY Payroll ENTRY
TALLY Service tax & tds ENTRY
C programming flow of controls
Php oops1
COMPUTER Tips ‘n’ Tricks
1 tally basic
Groups
VISUAL BASIC .net ii
Virus examples
Ad

Similar to C programming file handling (20)

PDF
Chapter 13.1.10
DOCX
Satz1
PPT
file.ppt
PPT
file handling, dynamic memory allocation
DOCX
Files let you store data on secondary storage such as a hard disk so that you...
PDF
Q2 Write a C program called myupper4.c to take as command line inpu.pdf
PPTX
Programming C- File Handling , File Operation
PPTX
Lecturer notes on file handling in programming C
PDF
4 text file
PPT
WK-12-13-file f classs 12 computer science from kv.
PPTX
6. chapter v
PPTX
files c programming handling in computer programming
PPTX
C-Programming File-handling-C.pptx
PPTX
C-Programming File-handling-C.pptx
PPT
C-Programming Chapter 5 File-handling-C.ppt
PPT
File Handling in c.ppt
PPT
slides3_077.ppt
PPTX
Presentation of file handling in C language
PPT
C Language Unit-5
Chapter 13.1.10
Satz1
file.ppt
file handling, dynamic memory allocation
Files let you store data on secondary storage such as a hard disk so that you...
Q2 Write a C program called myupper4.c to take as command line inpu.pdf
Programming C- File Handling , File Operation
Lecturer notes on file handling in programming C
4 text file
WK-12-13-file f classs 12 computer science from kv.
6. chapter v
files c programming handling in computer programming
C-Programming File-handling-C.pptx
C-Programming File-handling-C.pptx
C-Programming Chapter 5 File-handling-C.ppt
File Handling in c.ppt
slides3_077.ppt
Presentation of file handling in C language
C Language Unit-5

More from argusacademy (20)

PPSX
Css & dhtml
PPSX
Html table
PPSX
Html ordered & unordered list
PPSX
Html level ii
PPSX
Html frame
PPSX
Html forms
PPSX
Html creating page link or hyperlink
PPSX
Html basic
PPSX
Php string
PPSX
Php session
PPSX
Php if else
PPSX
Php creating forms
PPSX
Php create and invoke function
PPSX
Php array
PPSX
Sql query
PPSX
PDF
Oracle
PDF
Vb.net iv
PDF
Vb.net iii
PDF
Vb.net ii
Css & dhtml
Html table
Html ordered & unordered list
Html level ii
Html frame
Html forms
Html creating page link or hyperlink
Html basic
Php string
Php session
Php if else
Php creating forms
Php create and invoke function
Php array
Sql query
Oracle
Vb.net iv
Vb.net iii
Vb.net ii

Recently uploaded (20)

PDF
Insiders guide to clinical Medicine.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Complications of Minimal Access Surgery at WLH
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Classroom Observation Tools for Teachers
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
01-Introduction-to-Information-Management.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Institutional Correction lecture only . . .
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Insiders guide to clinical Medicine.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Complications of Minimal Access Surgery at WLH
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
2.FourierTransform-ShortQuestionswithAnswers.pdf
Classroom Observation Tools for Teachers
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Renaissance Architecture: A Journey from Faith to Humanism
01-Introduction-to-Information-Management.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Institutional Correction lecture only . . .
O7-L3 Supply Chain Operations - ICLT Program
Anesthesia in Laparoscopic Surgery in India
Week 4 Term 3 Study Techniques revisited.pptx
Cell Structure & Organelles in detailed.
Chapter 2 Heredity, Prenatal Development, and Birth.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