#include<stdio.h>
int main()
{
FILE *reading;
FILE *writing;
int condition,condition2;
char input[100];
char save[100];
printf("Type a name to open for reading : ");
scanf("%s",input);
reading = fopen(input,"r"); /* OPENS the file name we typed above for reading */
if(reading != NULL)
{
do
{
condition = fgets(save,30,reading);
printf("\n%s",save);
}while(condition != NULL);
}
else
{
printf("\nFile not found!!!!!\n");
}
getchar();
getchar();
fclose(reading);
return(0);
}
in the do while loop the programme picks up 100 characters from the file...
but what if a file is not hundred characters...
then the programme is showing lines 2-3 times for completion of hundred characters...
if a file has 50 characters then the programme will show 50 characters 2 times for completion of 100 characters....
means it will print the programme 2 times....
what to do...
what to do to avoid this ....