Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   File Handling Output problem (http://www.go4expert.com/forums/file-handling-output-t11866/)

rahulsince83 5Jul2008 04:29

File Handling Output problem
1 Attachment(s)
hi, This is a fairly simple program but i seem to be stuck a little. I 've been trying to write to a file all alphabets and then trying to read out the file every 5th alphabet from the beginning of the file. Program runs fine but its printing the first character at the beginning of file twice, both at 0th position and fifth position but after that program seems to go swiftly

here's the code:



void main(void)
 FILE *fp;
 char c;
 long i=0L;
 printf("Enter the characters now:");
    putc(' ',fp);
 printf("\nThe number of characters written in file is:%d",ftell(fp));
 printf("\nFile written successfully");
 printf("\n Now opening file for reading every fifth character from starting of file:");
 printf("Opening file failed:Error");

      printf("\nThe character %c is at position %d",c,ftell(fp));


and here's the output attached with file....

any help would be appreciated , I think i'm missing just something but everything else works fine......

Thanks in advance

All times are GMT +5.5. The time now is 23:50.