I am supposing that file is count.txt and is already exists....
so in initials of the main()
do this
*int count;
FILE* fp;
if((fp=fopen("count.txt","r"))==NULL)
{
printf("File does not exist\n");
exit(0):
}
fscanf(fp,"%d",&count);
count++;
fclose(fp);
fp=fopen("count.txt","w");
fprintf(fp,"%d",&count);
fclose(fp);
*
On Sat, Sep 17, 2011 at 9:36 PM, siva viknesh <[email protected]>wrote:
> hi anyone at least provide code using file handling.....i found this
> ques from other site
>
> On Sep 17, 6:35 pm, sivaviknesh s <[email protected]> wrote:
> > you have to write a program which tell about how many times it has run.
> ex:
> >
> > if you run first time it will print 1.
> > if you run second time it will print 2.
> > like this.
> >
> > this can easily done by File Handling but think other solution like IPC.
> >
> > after booting your system, your program's output start from 1....
> >
> > answers plz???
> >
> > --
> > Regards,
> > $iva
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
--
**Regards
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT ALLAHABAD
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.