New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



Resources » Articles/Knowledge Sharing » General »

File i/o handling in linux


Posted Date: 07 Nov 2009    Resource Type: Articles/Knowledge Sharing    Category: General
Author: karthickMember Level: Silver    
Rating: 3 out of 53 out of 53 out of 5Points: 2




#include
#define max 10
main()
{
int fp,i,no,s,ch=0;
char buf[max];
system("clear");
printf("\n Enter the no. of records:");
scanf("%d",&no);
fp=creat("kvr.txt");
for(i=0;i {
printf("\n Enter string for Record %d :",i+1);
scanf("%s",&buf);
s=write(fp,buf,max);
printf("\n Written to file -no.of bytes written=%d\n",s);
}
close(fp);
fp=open("kvr.txt");
while(ch!=-1)
{
printf("\n \n To view the content file");
printf("\n 0.View entire contents");
printf("\n no.for a particular record");
printf("\n-1.Exit\n");
scanf("%d",&ch);
printf("\n---------------------------------------------");
if(ch==0)
for(i=0;i {
read(fp,buf,max);
printf("\n %d %s",i+1,buf);
}
else if((ch>0)&&(ch<=no))
{
lseek(fp,SEEK_SET,(ch-1)*max);
read(fp,&buf,max);
printf("\n %d%a",ch,buf);
}
}
close(fp);
}





Responses to the resource: "File i/o handling in linux "

No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
CODING  .  SOURCE CODE  .  PROGRAM  .  C LANGUAGE  .  FILE  .  INPUT  .  OUTPUT  .  HANDLING  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Fibbonacci series program in unix
Previous Resource: Usage of “grep” filter program in unix
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
More Resources






Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

AdSense Revenue Sharing sites

ISC Technologies.
2006 - 2009 All Rights Reserved.